You are here

function maxlength_field_attach_form in Maxlength 7.3

Implements hook_field_attach_form().

File

./maxlength.module, line 136
Limit the number of characters in textfields and textareas and shows the amount of characters left.

Code

function maxlength_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  $fields = field_info_instances($entity_type, $form['#bundle']);

  // Check if any of the fields has a #maxlength_js setting.
  foreach ($fields as $field_name => $value) {
    if (isset($value['widget']['settings']['maxlength_js'])) {
      $elements[$field_name] = $value;
    }
  }
  if (isset($elements)) {
    _maxlength_children($form, $elements);
  }
}