Skip to content

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

@rocket-turtle

Description

@rocket-turtle

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions