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 Oct 1, 2020
1 parent f1bf4e6 commit 01e1700
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/helpers/rails_admin/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 01e1700

Please sign in to comment.