Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 Customize ActiveAdmin batch action collection form labels

I am using on Rails 4 and ActiveAdmin, a batch action collection form to capture input from the user as they perform a batch action ( in this case a batch mailer). Is there a way to customize the labels for the inputs?

Say for example:

    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. 

I dug in the documentation https://github.com/activeadmin/activeadmin/blob/master/docs/9-batch-actions.md#batch-action-forms but I was not able to. Any suggestions will be much appreciated.

like image 990
Joseworks Avatar asked May 31 '15 22:05

Joseworks


2 Answers

The form is rendered by modal_dialog.js.coffee, it should be possible to override and customize, for example see this declined pull request from @mmustala

like image 153
Piers C Avatar answered Nov 15 '22 10:11

Piers C


You don't have to use a symbol for the form input name. A string will also work. So in your case you could do:

batch_action :email, priority: 1 , form: {'Main Subject': :text,
                                             message: :textarea
                                            } do |ids, inputs|
    main_s = inputs['Main Subject']
    ...
end
like image 22
Johan C Avatar answered Nov 15 '22 08:11

Johan C