It would be nice if there was a way to keep a javascript object in a stimulus controller in sync with all the form elements.
It would work both ways. If you updated this.user.email
in stimulus controller, the form value would automatically change.
The real power would come from being able to define functionality within the HTML without the need of explicitly defining callbacks and show/hide functionality manually in the stimulus controller. Just a set of tags that allow you to run expressions against the form data and have that functionality added for you.
This would be great for simple validations and show/hide/disable/css functionality leaving you room in the Stimulus controller for more advanced features.
See data-stimulus-hidden
, data-stimulus-enabled
and data-stimulus-class