Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rlnorthcutt/17d7efa81ff57952d210 to your computer and use it in GitHub Desktop.
Save rlnorthcutt/17d7efa81ff57952d210 to your computer and use it in GitHub Desktop.
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
// If you have the Devel module turned on, use this to inspect the form array
// You can also use the form id to select a specific node type (like "article_node_form")
// dpm($form);
// dpm($form_id);
// The isset() here is just to prevent PHP notices for forms where its not present
if (isset($form['#node_edit_form']) && $form['#node_edit_form']) {
// Hide the publishing options & authoring information. The defaults will be used.
unset($form['options']);
unset($form['author']);
// Change the title of the revision fieldset, check the box by default,
// make sure its the top fieldset, and add a class for theming.
$form['revision_information']['#title'] = t('Track content changes');
$form['revision_information']['revision']['#default_value'] = TRUE;
$form['revision_information']['#weight'] = 0;
$form['options']['#attributes']['class'][] = 'checkbox-slider';
}
}
@rlnorthcutt
Copy link
Author

  1. Create a feature module
  2. Drop this code into the MYMODE.module file (where MYMODULE is the feature name).
  3. Modify as needed.

The cool thing is that you can use this approach to modify ANY form on the site, and you can also easily add any other hooks you like. Very simple, but very powerful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment