From 9dee3484448f8344f68213b1fb2bb516766101b7 Mon Sep 17 00:00:00 2001 From: "Tan, Hsi-nien" Date: Sun, 17 May 2020 07:38:45 -0500 Subject: [PATCH] Hide association input for deeply nested fields --- app/helpers/rails_admin/form_builder.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/rails_admin/form_builder.rb b/app/helpers/rails_admin/form_builder.rb index 75d5886aaf..f7fa937714 100644 --- a/app/helpers/rails_admin/form_builder.rb +++ b/app/helpers/rails_admin/form_builder.rb @@ -38,15 +38,15 @@ def fieldset_for(fieldset, nested_in) end def field_wrapper_for(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) + # 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 + if field.label 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 - else - field.nested_form ? field_for(field) : input_for(field) end end end