diff --git a/app/helpers/rails_admin/form_builder.rb b/app/helpers/rails_admin/form_builder.rb index 5c3b79a5d7..75d5886aaf 100644 --- a/app/helpers/rails_admin/form_builder.rb +++ b/app/helpers/rails_admin/form_builder.rb @@ -38,16 +38,14 @@ def fieldset_for(fieldset, nested_in) end def field_wrapper_for(field, nested_in) - if field.label - # do not show nested field if the target is the origin - unless nested_field_association?(field, nested_in) - @template.content_tag(:div, class: "form-group control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do + @template.content_tag(:div, class: "form-group control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do + if field.label + # do not show nested field if the target is the origin + unless nested_field_association?(field, nested_in) label(field.method_name, capitalize_first_letter(field.label), class: 'col-sm-2 control-label') + (field.nested_form ? field_for(field) : input_for(field)) end - end - else - @template.content_tag(:div, class: "form-group control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do + else field.nested_form ? field_for(field) : input_for(field) end end