' . t('About') . ''; $output .= '

' . t('The Inline Form Errors module makes it easier for users to identify which errors need to be resolved by providing a summary of all errors and by placing the individual error messages next to the form elements themselves. For more information, see the online documentation for the Inline Form Errors module.', [':inline_form_error' => 'https://www.drupal.org/docs/8/core/modules/inline-form-errors']) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Displaying error messages') . '
'; $output .= '
' . t('When a form is not filled in correctly (for example, if a required field is left blank), a warning message is displayed at the top of the form. This message links to the affected form elements, and individual error messages are displayed next to each form element.') . '
'; $output .= '
' . t('Displaying error messages in browsers with HTML5 form validation') . '
'; $output .= '
' . t('In browsers that support HTML5 form validation, users will first see the error messages generated by their browser. In this case, the inline form error messages are only displayed after the HTML5 validation errors have been resolved.') . '
'; return $output; } } /** * Implements hook_preprocess_HOOK() for form element templates. */ function inline_form_errors_preprocess_form_element(&$variables) { _inline_form_errors_set_errors($variables); } /** * Implements hook_preprocess_HOOK() for details element templates. */ function inline_form_errors_preprocess_details(&$variables) { _inline_form_errors_set_errors($variables); } /** * Implements hook_preprocess_HOOK() for fieldset element templates. */ function inline_form_errors_preprocess_fieldset(&$variables) { _inline_form_errors_set_errors($variables); } /** * Implements hook_preprocess_HOOK() for datetime form wrapper templates. */ function inline_form_errors_preprocess_datetime_wrapper(&$variables) { _inline_form_errors_set_errors($variables); } /** * Implements hook_element_info_alter(). */ function inline_form_errors_element_info_alter(array &$info) { \Drupal::classResolver()->getInstanceFromDefinition(RenderElementHelper::class) ->alterElementInfo($info); } /** * Populates form errors in the template. */ function _inline_form_errors_set_errors(&$variables) { $element = $variables['element']; if (!empty($element['#errors']) && empty($element['#error_no_message'])) { $variables['errors'] = $element['#errors']; } }