function track_field_changes_form_alter in Track Field Changes 7
Same name and namespace in other branches
- 8 track_field_changes.module \track_field_changes_form_alter()
Implement hook_form_alter(). (cant use hook_form_FORM_ID_alter(). here as the form ID changes from node to node)
File
- ./
track_field_changes.module, line 484 - The Track Field Changes module.
Code
function track_field_changes_form_alter(&$form, $form_state, $form_id) {
// If we're editing a node...
if (!empty($form['#node_edit_form'])) {
$node_types = variable_get('track_field_changes_node_types', array());
// And the show field is enabled for this node type.
$enable_log = variable_get('track_field_changes_enable_log_' . $form['type']['#value'], FALSE);
if (in_array($form['type']['#value'], $node_types) && $enable_log) {
$log = !$form['nid']['#value'] ? 'New ' . $form['type']['#value'] : '';
$form['track_field_changes'] = array(
'#type' => 'fieldset',
'#title' => t('Track Field Information'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#weight' => 35,
);
$form['track_field_changes']['track_field_changes'] = array(
'#type' => 'textarea',
'#title' => t('Track field log message'),
'#rows' => 4,
'#default_value' => !empty($node->track_field_changes) ? $node->track_field_changes : $log,
'#description' => t('Provide an explanation of the changes you are making.'),
'#maxlength' => 256,
);
}
}
}