Last active
February 23, 2016 01:30
-
-
Save rlnorthcutt/17d7efa81ff57952d210 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.