You are here

function _maxlength_cck_form_alter in Maxlength 6.2

Same name and namespace in other branches
  1. 5.2 maxlength.module \_maxlength_cck_form_alter()
  2. 7 maxlength.inc \_maxlength_cck_form_alter()
  3. 7.2 maxlength.inc \_maxlength_cck_form_alter()
1 call to _maxlength_cck_form_alter()
maxlength_form_alter in ./maxlength.module
Implementation of hook_form_alter().

File

./maxlength.inc, line 133
Business logic for maxlength

Code

function _maxlength_cck_form_alter(&$form, &$form_state, $form_id) {
  $form['field']['maxlength_' . $form['field_name']['#value'] . '_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Maxlength limit'),
    '#description' => t('If you want to use maxlength interactive counter and validation on a CCK field, let\'s leave the normal CCK length unlimited and set this value to the desired one to let maxlength count the real length of the text'),
    '#max_length_properties' => 6,
    '#default_value' => variable_get('maxlength_' . $form['field_name']['#value'], MAXLENGTH_DEFAULT_LENGTH),
  );
  $form['field']['maxlength_' . $form['field_name']['#value'] . '_js'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable remaining characters countdown for this field'),
    '#default_value' => variable_get('maxlength_' . $form['field_name']['#value'] . '_js', MAXLENGTH_DEFAULT_USE_JS),
    '#description' => t('This will enable a Javascript based count down, as well as the client side validation for this field. If no limit set this is ignored.'),
  );
  $form['field']['maxlength_' . $form['field_name']['#value'] . '_text'] = array(
    '#type' => 'textarea',
    '#title' => t('Count down message'),
    '#default_value' => variable_get('maxlength_' . $form['field_name']['#value'] . '_text', MAXLENGTH_DEFAULT_TEXT),
    '#description' => t('The text used in the Javascript message under the input, where "!limit", "!remaining" and "!count" are replaced by the appropriate numbers.'),
  );
  $form['#submit'][] = '_maxlength_cck_form_submit';
}