I am working on creating a module. I have given the module a weight of 1000. When I put the code below in hook_form_alter the menu, comment settings and attachment sections of a node creation form do not show up. When I place the code in hook_form_FORM_ID_alter (having removed hook_form_alter) the menu, comment settings and attachment sections on the node creation form show up. I used the Trace module for tracing but there didn't seem to be an option for hook_form_FORM_ID_alter. From this behavior I can only reach the conclusion that hook_form_alter's are called after hook_form_FORM_ID_alter's. It should be the opposite.
function author_form_author_node_form_alter(&$form, &$form_state) {
$form['author']=NULL;
$form['taxonomy']=NULL;
$form['options']=NULL;
$form['menu']=NULL;
$form['comment_settings']=NULL;
$form['files']=NULL;
$form['revision_information']=NULL;
$form['attachments']=NULL;
if($form["HIDEPREVIEW"]) {
$form['buttons']['preview']=NULL;
$form['buttons']['delete']=NULL;
}
// print_r($form);
// exit();
}
function author_form_alter(&$form, &$form_state, $form_id) {
if($form_id='author_node_form') {
$form['author']=NULL;
$form['taxonomy']=NULL;
$form['options']=NULL;
$form['menu']=NULL;
$form['comment_settings']=NULL;
$form['files']=NULL;
$form['revision_information']=NULL;
$form['attachments']=NULL;
if($form["HIDEPREVIEW"]) {
$form['buttons']['preview']=NULL;
$form['buttons']['delete']=NULL;
}
}
// print_r($form);
// exit();
}
Comments
Comment #1
chrislynch42 commentedComment #2
cweagansI can't speak to the design decisions in Form API, but I do know that you should not be setting form elements to null. Use http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.... instead.
Comment #3
damien tournoud commented