function _maxlength_content_form_alter in Maxlength 6.2
Same name and namespace in other branches
- 5.2 maxlength.module \_maxlength_content_form_alter()
- 7 maxlength.inc \_maxlength_content_form_alter()
- 7.2 maxlength.inc \_maxlength_content_form_alter()
@file Business logic for maxlength
1 call to _maxlength_content_form_alter()
- maxlength_form_alter in ./
maxlength.module - Implementation of hook_form_alter().
File
- ./
maxlength.inc, line 7 - Business logic for maxlength
Code
function _maxlength_content_form_alter(&$form, &$form_state, $form_id) {
$type = $form['type']['#value'];
// update the title as needed
if (isset($form['title']) && ($values = maxlength_get_values('title', $type))) {
$form['title']['#max_length_properties'] = $values;
}
// Update the body as needed
if (isset($form['body_field']['body']) && ($values = maxlength_get_values('body', $type))) {
$form['body_field']['body']['#max_length_properties'] = $values;
}
if (module_exists('content')) {
// Get a list of all the CCK fields for this content type
$info = content_types($type);
$list = array_keys($info['fields']);
// Update CCK fields as needed
foreach ($list as $field) {
if (isset($form[$field])) {
foreach (element_children($form[$field]) as $key) {
// For example #markup doens't have a #type element.
if (!empty($form[$field][$key]['#type']) && _maxlength_is_supported_widget($form[$field][$key]['#type'])) {
if ($values = maxlength_get_values($field, $type)) {
$form[$field][$key]['#max_length_properties'] = $values;
}
}
}
}
}
}
}