You are here

function maxlength_form_alter in Maxlength 6.2

Same name and namespace in other branches
  1. 5.2 maxlength.module \maxlength_form_alter()
  2. 5 maxlength.module \maxlength_form_alter()
  3. 6 maxlength.module \maxlength_form_alter()
  4. 7.3 maxlength.module \maxlength_form_alter()
  5. 7 maxlength.module \maxlength_form_alter()
  6. 7.2 maxlength.module \maxlength_form_alter()

Implementation of hook_form_alter().

File

./maxlength.module, line 27
Enables a max length countdown on node body, title and CCK textfields.

Code

function maxlength_form_alter(&$form, &$form_state, $form_id) {

  // This is not ideal, but will allow anyone to use the #max_length_properties
  // element
  $form['#after_build'][] = 'maxlength_after_build';

  // Editing the content.
  if ($form['#id'] == 'node-form') {
    module_load_include('inc', 'maxlength');
    _maxlength_content_form_alter($form, $form_state, $form_id);
  }
  elseif ($form['#id'] == 'comment-form') {
    module_load_include('inc', 'maxlength');
    _maxlength_comment_form_alter($form, $form_state, $form_id);
  }
  elseif ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
    module_load_include('inc', 'maxlength');
    _maxlength_content_type_form_alter($form, $form_state, $form_id);
  }
  elseif ($form_id == 'content_field_edit_form') {
    module_load_include('inc', 'maxlength');
    if (_maxlength_is_supported_widget($form['#field']['widget']['type'])) {
      _maxlength_cck_form_alter($form, $form_state, $form_id);
    }
  }
  elseif ($form_id == 'content_field_remove_form') {
    $form['#submit'][] = 'maxlength_field_remove_submit';
  }
}