link_to_add_association 添加两个部分而不是一个
link_to_add_association adding two partials instead of one
当我点击 "Add User" 时,添加了两行而不是一行。
See it here
new.html.slim :
= page_header
= simple_form_for @instance, url: admin_instance_users_path, method: :post do |f|
= f.error_notification
table.table.table-hover
thead
tr
th = t('common.name')
th = t('common.email')
th = t('common.role')
th
div.pull-right
= link_to_add_association t('.individual.add_user'), f, :invitations,
find_selector: 'tbody', insert_using: 'append'
tbody
= f.simple_fields_for :invitations, @instance.invitations.select(&:new_record?) do |invitation_form|
= render 'invitation_fields', f: invitation_form
= f.button :submit
_invitation_fields.html.slim(添加partial/column):
= content_tag_for(:tr, f.object, class: 'nested-fields') do
td = f.input :name, label: false, input_html: { class: 'invitation_name' }
td = f.input :email, required: true, label: false, input_html: { class: 'invitation_email' }
td = f.input :role,
as: :select,
collection: Instance::UserInvitation.roles.keys,
label: false,
label_method: lambda { |role_key| t("instance.users.role.#{role_key}") },
include_blank: false,
input_html: { class: 'invitation_role' }
td = link_to_remove_association t('.remove'), f
知道为什么吗?
结果是 HTML.
中的表格出现缩进错误
当我点击 "Add User" 时,添加了两行而不是一行。 See it here
new.html.slim :
= page_header
= simple_form_for @instance, url: admin_instance_users_path, method: :post do |f|
= f.error_notification
table.table.table-hover
thead
tr
th = t('common.name')
th = t('common.email')
th = t('common.role')
th
div.pull-right
= link_to_add_association t('.individual.add_user'), f, :invitations,
find_selector: 'tbody', insert_using: 'append'
tbody
= f.simple_fields_for :invitations, @instance.invitations.select(&:new_record?) do |invitation_form|
= render 'invitation_fields', f: invitation_form
= f.button :submit
_invitation_fields.html.slim(添加partial/column):
= content_tag_for(:tr, f.object, class: 'nested-fields') do
td = f.input :name, label: false, input_html: { class: 'invitation_name' }
td = f.input :email, required: true, label: false, input_html: { class: 'invitation_email' }
td = f.input :role,
as: :select,
collection: Instance::UserInvitation.roles.keys,
label: false,
label_method: lambda { |role_key| t("instance.users.role.#{role_key}") },
include_blank: false,
input_html: { class: 'invitation_role' }
td = link_to_remove_association t('.remove'), f
知道为什么吗?
结果是 HTML.
中的表格出现缩进错误