Active admin creates form in register_page

Using ActiveAdmin (0.5.1) I would like to create several different forms to create an object and save it in my database. I am trying to do this using ActiveAdmin.register_page, but I am having trouble trying to create a form. It seems that when using register_pageyou do not get the same method formas in the call register. Here is the code:

ActiveAdmin.register_page "New Object" do
  content do
    para "Here you can create new objects!"
    para "This content will be replaced with links to the specialized forms"
  end
end

And the code for one of the forms:

ActiveAdmin.register_page "Type 1" do
  menu :label => "Type 1", :parent => "New Object"

  content do
    panel "Attributes" do
      form do |f|
        f.input :color
        f.input :size
    end
  end
end

However, this form will not be displayed in any workable way. Also f.inputs, as well as many other methods that you can see in the examples (for example, this ), do not work. Is it possible to create fully functional forms with ActiveAdmin#register_page?

+5
source
2

(.. ), formtastic semantic_form_for :url :builder.

content do
  semantic_form_for MyObject.new, :url => admin_my_objects_url, :builder => ActiveAdmin::FormBuilder do |f|
    f.inputs "My Object" do
      f.input :color
      f.input :size
    end
    f.actions
  end
end

" ", , .

+2
ActiveAdmin.register_page "Families Placement" do
  menu label: "Populaire Familles"

  page_action :update, method: :post do
    Family.find(params['id']).update_attributes(id_1: params['id_1'], id_2: params['id_2'])
    redirect_to "/"
  end

  content do
    Family.all.order(id: :asc).each do |family|
        form action: "families_placement/update", method: :post do |f|
            columns do
          panel family.name do
            f.input :id, type: :hidden, value:  family.id, name: 'id'
            f.input :id_1, as: :select, collection: collect_posts, value: family.id_1, name: 'id_1'
            f.input :id_2, as: :select, collection: collect_posts, value: family.id_2, name: 'id_2'
            f.input :authenticity_token, type: :hidden, name: :authenticity_token, value: form_authenticity_token
            f.input :submit, type: :submit
          end
        end
      end
    end
  end
end

ActiveAdmin.

f.input :authenticity_token, type: :hidden, name: :authenticity_token, value: form_authenticity_token

: https://asafdav2.imtqy.com/2016/adding-forms-to-activeadmin-custom-pages/

0

All Articles