【问题标题】:Is there any way to use formtastic in activeadmin batch action form?有什么方法可以在 activeadmin 批处理操作表单中使用 formtastic 吗?
【发布时间】:2017-07-29 10:08:01
【问题描述】:

根据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,不支持高级表格配置(设置表单窗口的大小)。有什么方法可以将其更改为格式格式,例如:

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

【问题讨论】:

    标签: ruby-on-rails ruby activeadmin formtastic


    【解决方案1】:

    可能不会。该表单在batch_action_form.rb 中构建,但由前端在modal_dialog.js.coffee 中动态呈现,当前使用的是jQuery。有创意rewriting batch action forms 是可能的,但我不推荐。如果您的批处理操作很复杂,请尝试查看 Custom Pages 是否可以满足您的需求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多