有没有办法在 activeadmin 批处理操作表单中使用 formtastic?
Is there any way to use formtastic in activeadmin batch action form?
根据activeamdin文档,我们可以这样做:
batch_action :flag, form: {
type: %w[Offensive Spam Other],
reason: :text,
notes: :textarea,
hide: :checkbox,
date: :datepicker
} do |ids, inputs|
# inputs is a hash of all the form fields you requested
redirect_to collection_path, notice: [ids, inputs].to_s
end
但是,上面的表格不是formtastic,不支持高级table配置(设置表格的大小window)。有什么办法可以将其更改为 formtastic 格式,例如:
form do |f|
f.semantic_errors # shows errors on :base
f.inputs # builds an input field for every attribute
f.actions # adds the 'Submit' and 'Cancel' buttons
end
可能不会。内置表格batch_action_form.rb but rendered dynamically by the front end in modal_dialog.js.coffee, which is currently using jQuery. It is possible to get creative rewriting batch action forms but I can't recommend it. If your batch actions are complex try seeing if Custom Pages可以满足您的需求
根据activeamdin文档,我们可以这样做:
batch_action :flag, form: {
type: %w[Offensive Spam Other],
reason: :text,
notes: :textarea,
hide: :checkbox,
date: :datepicker
} do |ids, inputs|
# inputs is a hash of all the form fields you requested
redirect_to collection_path, notice: [ids, inputs].to_s
end
但是,上面的表格不是formtastic,不支持高级table配置(设置表格的大小window)。有什么办法可以将其更改为 formtastic 格式,例如:
form do |f|
f.semantic_errors # shows errors on :base
f.inputs # builds an input field for every attribute
f.actions # adds the 'Submit' and 'Cancel' buttons
end
可能不会。内置表格batch_action_form.rb but rendered dynamically by the front end in modal_dialog.js.coffee, which is currently using jQuery. It is possible to get creative rewriting batch action forms but I can't recommend it. If your batch actions are complex try seeing if Custom Pages可以满足您的需求