Skip to content
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

For invalid fields, ensure that the invalid feedback/error message is associated with the relevant form field using aria-describedby #743

Open
rocket-turtle opened this issue Nov 26, 2024 · 0 comments

Comments

@rocket-turtle
Copy link

Currently we are facing the problem that we need to add aria-describedby labels to the input for error messages.

Bootstrap also recomends this: https://getbootstrap.com/docs/5.3/forms/validation/#server-side

For invalid fields, ensure that the invalid feedback/error message is associated with the relevant form field using aria-describedby (noting that this attribute allows more than one id to be referenced, in case the field already points to additional form text).

In Rails you can do it like this: https://github.com/rails/rails/blob/d3b2fcb4ffee825f8e9ad8f4bacc859978aebaed/actionview/lib/action_view/helpers/form_helper.rb#L1766

      #   <%= form_for @post do |f| %>
      #     <%= f.label :title %>
      #     <%= f.text_field :title, aria: { describedby: f.field_id(:title, :error) } %>
      #     <%= tag.span("is blank", id: f.field_id(:title, :error) %>
      #   <% end %>

Any ideas how to add it for bootstrap_form?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant