ciembor
ciembor

Reputation: 7337

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?

Upvotes: 7

Views: 3303

Answers (1)

Alfreddd
Alfreddd

Reputation: 1971

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

Upvotes: 16

Related Questions