You are here

function webform_hints_add_title in Webform Hints 6

Same name and namespace in other branches
  1. 7 webform_hints.module \webform_hints_add_title()

Alter the passed webform element, add the elements title to the title attribute, and unset the label or title of the element.

1 string reference to 'webform_hints_add_title'
webform_hints_form_alter in ./webform_hints.module
Implementation of hook_form_alter().

File

./webform_hints.module, line 65

Code

function webform_hints_add_title(&$element) {

  // Skip the boolean #tree.
  if (is_array($element)) {
    $fieldtypes = array(
      'textfield',
      'textarea',
      'webform_email',
      'email',
    );
    if (in_array($element['#type'], $fieldtypes)) {
      $element['#attributes']['title'] = $element['#title'];
      $element['#attributes']['placeholder'] = $element['#title'];
    }
  }
}