简体   繁体   中英

Add a custom action button in active_admin input form

Iam working on active_admin form. my requirement is to add a button beside a input box to create new project How to add a action item inside a form ?

form do |f|
    f.semantic_errors *f.object.errors.keys
    f.inputs "Details" do
      f.input :task
      f.input :project
      f.input :members, :input_html => { :class => "chosen-input" }, :label => 'Assigned To'
      f.actions
    end
 end

i want to add a new project button beside input field project

Though it is a very old question, stil i was also looking for the answer, This is how to do it:

just add it after f.input :project :

f.button "New Project", formaction: "new_entry", class: "some_class"

Then using member_action :

member_action :new_entry, method: :patch do
    
end
inputs 'Details' do
  li do
    label "Project"

    span do
      "here is your project input field"
    end

    span do
      "here is your button"
    end
  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM