Rails 4 Customize ActiveAdmin Collective Action Form Shortcuts

I use Rails 4 and ActiveAdmin, a collection of group actions, to capture user input when they perform a batch action (in this case, a batch mail program). Is there a way to configure labels for 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 up https://github.com/activeadmin/activeadmin/blob/master/docs/9-batch-actions.md#batch-action-forms in the documentation, but I couldn’t. Any suggestions would be highly appreciated.

+6
source share
2 answers

The form is visualized by modal_dialog.js.coffee, it can be redefined and customized, for example, see this rejected request for transfer from @mmustala

+1
source

You do not need to use a character to enter the name of the form. The string will also work. Therefore, in your case, you can do:

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

Source: https://habr.com/ru/post/988280/


All Articles