function form_placeholder_process_element in Form Placeholder 8
Same name and namespace in other branches
- 7 form_placeholder.module \form_placeholder_process_element()
Element process callback.
Parameters
array $element: The render array element.
\Drupal\Core\Form\FormStateInterface $form_state: The FormStateInterface object for this form
Return value
array The processed element.
1 string reference to 'form_placeholder_process_element'
- form_placeholder_element_info_alter in ./
form_placeholder.module - Implements hook_element_info_alter().
File
- ./
form_placeholder.module, line 41 - Use field label as placeholder for all elements in chosen form.
Code
function form_placeholder_process_element($element, &$form_state) {
$form = $form_state
->getCompleteForm();
$form_placeholder = NULL;
if (isset($element['#form_placeholder'])) {
$form_placeholder = $element['#form_placeholder'];
}
elseif (isset($form['#form_placeholder'])) {
$form_placeholder = $form['#form_placeholder'];
}
if (!is_null($form_placeholder)) {
$action = $form_placeholder == TRUE ? 'include' : 'exclude';
if ($element['#type'] == 'form') {
$element['#attributes']['class'][] = 'form-placeholder-' . $action . '-children';
}
else {
$element['#attributes']['class'][] = 'form-placeholder-' . $action;
}
}
form_placeholder_attach($element);
return $element;
}