Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove "Add new" button from ActiveAdmin has_many form helper

I have nested resources in active admin edit page, but I would like only to allow admin to edit content of existing resources, not to add new nested resources. My code looks like that:

  form do |f|
    f.inputs do
      f.input :author
      f.input :content
      f.has_many :comments do |comment_form|
        comment_form.input :content
        comment_form.input :_destroy, as: :boolean, required: false, label: 'Remove'
      end
    end
    f.actions
  end

But it add's "Add new comment" button under inputs. How can I disable it, and leave only f.actions buttons for main form?

like image 597
ciembor Avatar asked Oct 17 '13 13:10

ciembor


1 Answers

Starting from v0.6.1 you can pass new_record: false to hide the "Add new" button

f.has_many :comments, new_record: false do |comment_form|
...
end

The commit 4b58b8

like image 60
Alfreddd Avatar answered Sep 23 '22 20:09

Alfreddd