diff --git a/app/helpers/rails_admin/form_builder.rb b/app/helpers/rails_admin/form_builder.rb index 75d5886aaf..facfc84ea9 100644 --- a/app/helpers/rails_admin/form_builder.rb +++ b/app/helpers/rails_admin/form_builder.rb @@ -38,13 +38,12 @@ def fieldset_for(fieldset, nested_in) end def field_wrapper_for(field, nested_in) + # do not show nested field if the target is the origin + return if 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 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 + label(field.method_name, capitalize_first_letter(field.label), class: 'col-sm-2 control-label') + + (field.nested_form ? field_for(field) : input_for(field)) else field.nested_form ? field_for(field) : input_for(field) end