activeadmin_addons icon indicating copy to clipboard operation
activeadmin_addons copied to clipboard

[BUG] batch_action + form + select: no value submitted

Open gap777 opened this issue 5 months ago • 1 comments

Describe the bug Setup an AA batch_action with a form, containing a select. I'm using dynamic form inputs, but the problem occurs with static ones:

batch_action :doit, form: -> { {user: User.pluck(:name, :id)} } do |ids, inputs|
  User.find(inputs[:user])
  # ...
end

Select some rows on the index page, choose the batch_action. Observe that the select is properly rendered. However, when OK is pressed, the selection submits form data to the server, and the input is always blank.

Expected behavior The selected option's value should be submitted in the body of the form post action.

Additional context

Investigation details:

  • AA ModalDialog is correctly setting up the select and options
  • After slimselect has initialized, and before submitting the form, monitoring the state of the (hidden) select as options are selected, reveals the problem has already occurred. Normally, in AA w/ slimselect (eg edit page), as the option is changed, the (hidden) select.value is updated (as is select.selectedIndex). In this case, the (hidden) select.value is always blank. Furthermore, at this point (after ss is initialized, and the user can interact with the select), all the options in the (hidden) select are lacking a value attribute contents. (They are present, but blank). Again, comparing to AA w/ slimselect (eg edit page), the (hidden) select options have meaningful value attributes.

gap777 avatar Jul 20 '25 01:07 gap777