function _maxlength_content_type_form_alter in Maxlength 5.2
Same name and namespace in other branches
- 6.2 maxlength.inc \_maxlength_content_type_form_alter()
- 7 maxlength.inc \_maxlength_content_type_form_alter()
- 7.2 maxlength.inc \_maxlength_content_type_form_alter()
1 call to _maxlength_content_type_form_alter()
- maxlength_form_alter in ./
maxlength.module - Implementation of hook_form_alter().
File
- ./
maxlength.module, line 111
Code
function _maxlength_content_type_form_alter($form_id, &$form) {
$type = $form['#node_type']->type;
$labels = array(
'-3' => 'title',
'-1 ' => 'body',
);
foreach ($labels as $weigh => $label) {
// bit of a hack to allow us to position the input fields correctly
$form['submission'][$label . '_label']['#weight'] = $weight - 1;
$form['submission'][MAXLENGTH_NODE_TYPE . $label] = array(
'#type' => 'fieldset',
'#weight' => $weight,
'#title' => t('Limit !type length', array(
'!type ' => $label,
)),
'#collapsible' => TRUE,
'#collapsed' => strlen(variable_get($type . '_' . $label, '')) == 0,
);
$form['submission'][MAXLENGTH_NODE_TYPE . $label][MAXLENGTH_NODE_TYPE . $label] = array(
'#type' => 'textfield',
'#title' => t('!label max length', array(
'!label' => ucwords($label),
)),
'#field_suffix' => t('characters'),
'#return_value' => 1,
'#size' => 4,
'#default_value' => variable_get(MAXLENGTH_NODE_TYPE . $label . '_' . $type, ''),
'#description' => t('Maximum number of characters allowed for the !type field of this content type. Leave blank for an unlimited size.', array(
'!type' => $label,
)) . '<br/>' . '<b>' . t('Please remember, it counts all characters, including HTML, so may not work as expected with rich text editors e.g. FCKeditor / tinyMCE.') . '</b>',
);
$form['submission'][MAXLENGTH_NODE_TYPE . $label][MAXLENGTH_NODE_TYPE . $label . '_js'] = array(
'#type' => 'checkbox',
'#title' => t('Enable remaining characters countdown for the !label', array(
'!label' => ucwords($label),
)),
'#default_value' => variable_get(MAXLENGTH_NODE_TYPE . $label . '_js_' . $type, '0'),
'#description' => t('This will enable a Javascript based count down, as well as the client side validation for the !type field of this content type. If no limit set this is ignored.', array(
'!type' => $label,
)),
);
$form['submission'][MAXLENGTH_NODE_TYPE . $label][MAXLENGTH_NODE_TYPE . $label . '_text'] = array(
'#type' => 'textarea',
'#title' => t('!label count down message', array(
'!label' => ucwords($label),
)),
'#default_value' => variable_get(MAXLENGTH_NODE_TYPE . $label . '_text_' . $type, 'Content limited to !limit characters, remaining: <strong>!remaining</strong>'),
'#description' => t('The text used in the Javascript message under the !type input, where "!limit" and "!remaining" are replaced by the appropriate numbers.', array(
'!type' => $label,
)),
);
}
}