trestle icon indicating copy to clipboard operation
trestle copied to clipboard

How to add stimulus controllers in forms

Open troya2 opened this issue 2 years ago • 0 comments

I am trying to add a stimulus controller to a form field to, for example, uncheck all or check all checkboxes in a collection_check_boxes field set.

I tried connection_check_boxes :user_ids, User.all, :id, :name, data: { controller: 'checkbox-selection' } but the data element is dropped since it's not part of the connection_check_boxes method.

Is there a way to accomplish this, or would this require a code change? If the latter, any suggestions on a way forward? I'd consider doing a PR for this as it seems generally useful for all form fields and other HTML elements provided by the DSL.

troya2 avatar Mar 05 '22 23:03 troya2