function diff_form_alter in Diff 6
Same name and namespace in other branches
- 5.2 diff.module \diff_form_alter()
- 5 diff.module \diff_form_alter()
- 6.2 diff.module \diff_form_alter()
- 7.2 diff.module \diff_form_alter()
Implementation of hook_form_alter(). Used to add a 'Preview changes' button on the node edit form.
File
- ./
diff.module, line 451 - Provides functionality to show a diff between two node revisions.
Code
function diff_form_alter(&$form, $form_state, $form_id) {
if (isset($form['type']['#value']) && $form['type']['#value'] . '_node_form' == $form_id) {
// Node editing form.
// Add a 'Preview changes' button.
if (variable_get('show_preview_changes_' . $form['type']['#value'], TRUE) && $form['nid']['#value'] > 0) {
$form['buttons']['preview_changes'] = array(
'#type' => 'submit',
'#value' => t('Preview changes'),
'#weight' => 12,
'#submit' => array(
'diff_node_form_build_preview_changes',
),
);
}
}
elseif ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
// Node type edit form.
// Add checkbox to activate 'Preview changes' button per node type.
$form['workflow']['show_preview_changes'] = array(
'#type' => 'checkbox',
'#title' => t('Show %preview_changes button on node edit form', array(
'%preview_changes' => t('Preview changes'),
)),
'#prefix' => '<strong>' . t('Preview changes') . '</strong>',
'#weight' => 10,
'#default_value' => variable_get('show_preview_changes_' . $form['#node_type']->type, TRUE),
);
}
}