function _maxlength_content_form_alter in Maxlength 7.2
Same name and namespace in other branches
- 5.2 maxlength.module \_maxlength_content_form_alter()
- 6.2 maxlength.inc \_maxlength_content_form_alter()
- 7 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'])) {
$form['title']['#after_build'] = array(
'_maxlength_format_element',
);
$form['title']['#max_length_properties'] = array(
$form['title']['#default_value'],
'title',
'title',
$type,
);
}
// Get a list of all fields for this content type
//$list = array_keys(content_fields(NULL, $type));
$list = array_keys(field_info_instances('node', $type));
// Update CCK fields as needed
foreach ($list as $field) {
$field_info = field_info_field($field);
if ($field_info['module'] == 'text' && ($field_info['type'] == 'text' || ($field_info['type'] = 'text_long')) && is_array($form[$field])) {
foreach (element_children($form[$field]) as $key) {
foreach (element_children($form[$field][$key]) as $index) {
if (is_numeric($index)) {
$form[$field][$key][$index]['#after_build'] = array(
'_maxlength_format_element',
);
$default_value = isset($form[$field][$key][$index]['value']['#default_value']) ? $form[$field][$key][$index]['value']['#default_value'] : (isset($form[$field][$key][$index]['#default_value']) ? $form[$field][$key][$index]['#default_value'] : '');
$form[$field][$key][$index]['#max_length_properties'] = array(
$default_value,
$field,
str_replace('_', '-', $field) . '-' . $key . '-' . $index . '-value',
$type,
);
}
}
}
}
}
}