You are here

function name_component_description_after_build_label_alter in Name Field 8

Afterbuild for setting the correct ID on the description labels.

Parameters

array $element: The form element that needs the for attribute set.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form element.

1 string reference to 'name_component_description_after_build_label_alter'
name_element_render_component in ./name.module
Helper function to render a component within a name element.

File

./name.module, line 536
Defines an API for displaying and inputing names.

Code

function name_component_description_after_build_label_alter(array $element, FormStateInterface $form_state) {
  if (!empty($element['#description']) && !empty($element['#id']) && is_array($element['#description'])) {
    $element['#description']['#for'] = $element['#id'];
  }
  return $element;
}