Skip to content

Commit

Permalink
Hide association input for deeply nested fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jubilee2 committed May 17, 2020
1 parent f1bf4e6 commit 9dee348
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/helpers/rails_admin/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9dee348

Please # to comment.