You are here

function field_placeholder_field_widget_form_alter in Field placeholder 7

Same name and namespace in other branches
  1. 7.2 field_placeholder.module \field_placeholder_field_widget_form_alter()

Implements hook_field_widget_form_alter().

File

./field_placeholder.module, line 30
Field placeholder module hooks and main functionality.

Code

function field_placeholder_field_widget_form_alter(&$element, &$form_state, $context) {
  if (in_array($context['instance']['widget']['type'], field_placeholder_get_widget_types()) && isset($context['instance']['placeholder'])) {
    $placeholder = field_placeholder_get_widget($context['instance']['widget']['type']);
    $instance = module_exists('i18n_field_placeholder') ? i18n_string_object_translate('field_instance', $context['instance']) : $context['instance'];
    if ($placeholder) {
      $element[$placeholder]['#attributes']['placeholder'] = check_plain($instance['placeholder']);
    }
    else {
      $element['#attributes']['placeholder'] = check_plain($instance['placeholder']);
    }
  }
}