-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
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? Sign in to your account
form input id collisions #1001
Comments
@manveru can you give a more concrete example of what you're facing? |
My actual usage is more complicated, but the problem is quite easy to reproduce on a tiny scale. [user1, user2].each do |user|
form_for User::Update do
mount Users::FormFields, SaveUser.new(user)
submit r("save").t, data_disable_with: r("saving").t, class: "button is-link"
end
end This will generate fields like these (slightly different tag structure since I adapted it for Bulma, but the
Now the issue is that the This not only violates the HTML spec, which doesn't allow duplicated I hope this clarifies the issue a bit. |
I was thinking about this today... Would appending the model's The other option I thought of is some sort of page level context store for how many times a specific ID gets generated with some count. Then you end up having something like [user1, user2].each do |user|
mount UserForm, user: user
end But doing it on a global scale means that if you mount this user form on several pages, it's possible you might have a field that's like |
When there are more forms on a single page, the
id
attributes is not unique for each label/input.That is a problem for accessibility and usability, since now clicking the label may activate completely unrelated input.
One can work around this by manually setting the id for each tag for now, but it would be awesome if there was a way to do this automatically. Maybe generating a random prefix for each
form_for
instance?The text was updated successfully, but these errors were encountered: