【问题标题】:Rails 4 Customize ActiveAdmin batch action collection form labelsRails 4 自定义 ActiveAdmin 批处理操作集合表单标签
【发布时间】:2015-05-31 22:44:33
【问题描述】:

我在 Rails 4 和 ActiveAdmin 上使用批处理操作收集表单,用于在用户执行批处理操作(在本例中为批处理邮件程序)时捕获用户的输入。有没有办法自定义输入的标签?

比如说:

    batch_action :email, priority: 1 , form: {main_subject: :text,
                                              message: :textarea
                                             } do |ids, inputs|
  batch_action_collection.find(ids).each do |user|
   ContactBatchMailer.contact_batch_email(main_subject, message,...


    Instead of having "main_subject", I would like to display a better formatted text, like "Main Subject", or even better, something more descriptive than the variable name by itself. 

我在文档https://github.com/activeadmin/activeadmin/blob/master/docs/9-batch-actions.md#batch-action-forms 中进行了挖掘,但我无法做到。 任何建议将不胜感激。

【问题讨论】:

    标签: ruby-on-rails forms activeadmin batch-processing labels


    【解决方案1】:

    表单由modal_dialog.js.coffee渲染,应该可以覆盖和自定义,例如见@mmustala的declined pull request

    【讨论】:

    • 谢谢你,码头 C!
    【解决方案2】:

    您没有为表单输入名称使用符号。字符串也可以。所以在你的情况下你可以这样做:

    batch_action :email, priority: 1 , form: {'Main Subject': :text,
                                                 message: :textarea
                                                } do |ids, inputs|
        main_s = inputs['Main Subject']
        ...
    end
    

    【讨论】:

    • 谢谢!这是一个救生员!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-17
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    相关资源
    最近更新 更多