You are here

function form_placeholder_process_element in Form Placeholder 7

Same name and namespace in other branches
  1. 8 form_placeholder.module \form_placeholder_process_element()

Element process callback.

Parameters

array $element: The render array element.

Return value

array The processed element.

2 string references to 'form_placeholder_process_element'
form_placeholder_element_info_alter in ./form_placeholder.module
Implements hook_element_info_alter().
form_placeholder_form_webform_client_form_alter in ./form_placeholder.module
Implements hook_form_BASE_FORM_ID_alter().

File

./form_placeholder.module, line 88
Use field label as placeholder for all elements in choosen form.

Code

function form_placeholder_process_element($element) {
  if (isset($element['#form_placeholder'])) {
    $action = $element['#form_placeholder'] == TRUE ? 'include' : 'exclude';
    if ($element['#type'] == 'form') {
      $element['#attributes']['class'][] = 'form-placeholder-' . $action . '-children';
    }
    else {
      $element['#attributes']['class'][] = 'form-placeholder-' . $action;
    }
  }
  if ($element['#type'] == 'form') {
    form_placeholder_attach($element);
  }
  return $element;
}