The form_with
helper doesn't generate id
s for form elements, and therefore doesn't generate for
attributes either. This differs from the old form_tag
and form_for
helpers.
If you want to use form_with
instead of the deprecated form_tag
and form_for
helpers, but you want id
s to generate, you need to add this to your config:
config.action_view.form_with_generates_ids = true
id
generation is useful in some cases because certain front-end things may require it. On top of that, it seems to me that not generating for
attributes means that forms generated with form_with
have less a11y.
I'm currently working in an older codebase where form element id
s are required, and my knee-jerk reaction is to enable the above config setting so I can use form_with
without having to manually set IDs for every element.
What is the reasoning for making form_with
not generate ids
by default? I'm concerned that I'm missing something here, since I assume there's a good reason for the decision.