For accessibility purposes, each webform should contain a message at the top stating: (*) indicates that a field is required. Asterisks currently appear after every required field in a form, but there is no message at the top of the page informing non-sighted users what the asterisk means.

Would it be possible to also have this enabled out of the box?

Comments

DanChadwick’s picture

How is webform different from core forms?

Liam Morland’s picture

If you want to override the required marker on your own site, you can implement theme_form_required_marker().

/**
 * Implements theme_form_required_marker().
 */
function yourmodule_form_required_marker($variables) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();
  $attributes = array(
    'class' => 'form-required',
    'title' => $t('This field is required.'),
  );
  return '<abbr' . drupal_attributes($attributes) . '>* <span>' . $t('(required)') . '</span></abbr>';
}
DanChadwick’s picture

Category: Feature request » Support request
Priority: Minor » Normal
Status: Active » Fixed

Answered by #2, I think.

Liam Morland’s picture

I think it would be reasonable to have a single notice at the top explaining what the asterisk means. The form API could check the form for the presence of required fields and add that the notice if there is more than one. If there is just one, the notice should be with the field.

However, something like this would best be done in Drupal core so that it would work with all forms, not just Webform. There is likely a hook that anyone could use to do this on their own site.

DSheffler’s picture

Title: Include an message indicating that an asterick indicated that a field is required » Include a message indicating that an asterick indicated that a field is required
Liam Morland’s picture

Title: Include a message indicating that an asterick indicated that a field is required » Include a message indicating that an asterisk indicated that a field is required
mgifford’s picture

@Liam Morland do you want to open a new issue in D8 for a "single notice at the top explaining what the asterisk means"?

Liam Morland’s picture

While I think it would be reasonable to do it, I don't think it is necessary. Most people know what a red asterisk means and if they don't, the abbr title is there and they will encounter the validation message if they miss a component. So, anyone that doesn't know what the red asterisk means soon will.

DSheffler’s picture

@Liam Morland, is that the case for screen readers? If you go with the strictest sense of 508 compliance, the message should be there.

Liam Morland’s picture

In D8, the asterisk is added by CSS. Screen readers get the HTML5 "required" attribute plus @aria-required (I don't see the point in having both). See #2121775: Make the markup associated with the required star on field items silent.

Liam Morland’s picture

mgifford’s picture

Right.. Good point.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.