入力ボックスの上にあるラベルにエラーが表示されました。
以下のコードでは、エラーをクラスに与えました。これは、配置などのためにフォーマットすることができますが、入力ボックスの下に空白のdivや何かがあります。ジョイント。私の初期化子で
<%= f.input :name, :required => true, :label_html => { :class => 'edit_form_titles' }, :error_html => { :class => 'cant_be_blank'} %>
/simple_form.rbがあった:
config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper :tag => 'div', :class => 'controls' do |input|
input.use :input
input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
input.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
end
end
が、私はこれを変更:入力ボックスと私の下の空白の空きスペースを処分した
config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
b.use :html5
b.use :placeholder
b.wrapper :tag => 'div', :class => 'label-error' do |input|
b.use :label
b.use :error, :wrap_with => { :tag => 'span', :class => 'help-block' }
end
b.wrapper :tag => 'div', :class => 'controls' do |ba|
ba.use :input
ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
end
end
私のcant_be_blankクラスをフォーマットして、ラベル内のテキストのすぐ隣にテキストが表示されるようにすることができます。
これは役立つ可能性があります:http://stackoverflow.com/questions/10911121/displaying-simple-form-error-messages-in-top-div –