我在主动管理员中创建了一个表单但是field_for for没有显示多个嵌套属性。
这是我的代码:
ActiveAdmin.register Application do
actions :all, :except => [:destroy]
permit_params :agent_code, :operator_id,
customer_attributes: [:email, person_attributes:[:name, :title_type, :first_name, :middle_name,
:last_name, :id_type, :id_number, :birthday, :home_phone, :mobile_phone, :work_phone], next_of_kin_attributes:
[:first_name, :last_name, :home_phone]]
form do |f|
f.inputs "Your Details" do
f.input :agent_code
f.input :operator_id, as: :select, prompt: "Operator", collection: Operator.all
f.fields_for :customer do |customer|
customer.fields_for :person do |person|
person.input :name, as: :hidden
person.input :title_type, as: :select, prompt: "Title", class: 'selectpicker', collection: Person::TITLE_TYPES.map{|title_type| [ title_type[1], title_type[0] ]}
person.input :first_name
person.input :middle_name
person.input :last_name
person.select :id_type, as: :select, collection: Person::ID_TYPES.map{|id_type| [ id_type[1], id_type[0] ]} , prompt: 'ID Type', class: 'id_select_box'
person.input :id_number
person.input :birthday
person.input :home_phone
person.input :mobile_phone
person.input :work_phone
end
customer.input :email
customer.fields_for :next_of_kin do |next_of_kin|
next_of_kin.input :first_name
next_of_kin.input :last_name
next_of_kin.input :home_phone
end
end
end
f.actions
end
end
在上面的代码中,当我编写Person属性时,它在前端是可见的,但是当我写下next_of_kin_attributes时,后者显示但前者不是。所以基本上我需要弄清楚我们如何在活动管理中执行多级嵌套属性。
如果我在两个字段之间写了customer_attributes attributes(:email)
,则它不会显示两个fields_for属性中的任何一个。
提前致谢!