diff --git a/app/views/rails_admin/main/_form_nested_many.html.erb b/app/views/rails_admin/main/_form_nested_many.html.erb index 67144e7fe..7a92f1bd9 100644 --- a/app/views/rails_admin/main/_form_nested_many.html.erb +++ b/app/views/rails_admin/main/_form_nested_many.html.erb @@ -3,7 +3,7 @@ - <% unless field.nested_form[:update_only] || !field.inline_add %> + <% if field.inline_add %> <%= form.link_to_add " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, field.name, { class: 'btn btn-info' } %> <% end %> diff --git a/app/views/rails_admin/main/_form_nested_one.html.erb b/app/views/rails_admin/main/_form_nested_one.html.erb index 976775b8b..54906808d 100644 --- a/app/views/rails_admin/main/_form_nested_one.html.erb +++ b/app/views/rails_admin/main/_form_nested_one.html.erb @@ -4,7 +4,7 @@ - <% unless field.nested_form[:update_only] || !field.inline_add %> + <% if field.inline_add %> <%= form.link_to_add " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, field.name, { class: 'btn btn-info', :'data-add-label' => " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".gsub("\n", "") } %> <% end %> diff --git a/spec/integration/widgets/nested_many_spec.rb b/spec/integration/widgets/nested_many_spec.rb index 85076df20..3121f3956 100644 --- a/spec/integration/widgets/nested_many_spec.rb +++ b/spec/integration/widgets/nested_many_spec.rb @@ -108,21 +108,13 @@ context 'with nested_attributes_options given' do before do allow(FieldTest.nested_attributes_options).to receive(:[]).with(any_args). - and_return(allow_destroy: true, update_only: false) - end - - it 'does not show add button when :update_only is true' do - allow(FieldTest.nested_attributes_options).to receive(:[]).with(:nested_field_tests). - and_return(allow_destroy: true, update_only: true) - visit new_path(model_name: 'field_test') - is_expected.to have_selector('.toggler') - is_expected.not_to have_selector('#field_test_nested_field_tests_attributes_field .add_nested_fields') + and_return(allow_destroy: true) end it 'does not show destroy button except for newly created when :allow_destroy is false', js: false do nested_field_tests allow(FieldTest.nested_attributes_options).to receive(:[]).with(:nested_field_tests). - and_return(allow_destroy: false, update_only: false) + and_return(allow_destroy: false) visit edit_path(model_name: 'field_test', id: field_test.id) expect(find('#field_test_nested_field_tests_attributes_0_title').value).to eq('title 1') is_expected.not_to have_selector('form .remove_nested_fields')