Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
<%= f.label :name %>
<%= f.text_field :name %>
I would expect it to assign ids so the label functions correctly as it does with form_for
which produces the following output:
<input type="text" name="model[name]" id="model_name">
form_with produces a label with an invalid for attribute since the id is missing from the input:
<input type="text" name="model[name]">
The text was updated successfully, but these errors were encountered:
That is by design. form_with don't assign id's to inputs.
Sorry, something went wrong.
@rafaelfranca but it still produces for attribute. The form doesn't look nice this way:
form.text_field :name, id: "object_class_name_content"
And it's impossible to turn on generating ids, because of hardcoded https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/form_helper.rb#L717
@kaspth Why was it designed this way?
@morgoth See the first point here: #25197 😊
If that is the behavior, shouldn't the for attribute be removed from the label as well as the id on the input?
No branches or pull requests