background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount

Repositioning a node form element manually using the form_alter hook

Eric.London's picture

Drupal 6 comes with greatly improved usability, such as the ability to reposition node form elements by dragging and dropping (unlike Drupal 5, which made you assign a numeric weight to each item). But what about the form elements that Drupal does not let you adjust, like the revision information? You can implement a form_alter hook to solve this one...

<?php
function MYMODULE_form_alter(&$form, $form_state, $form_id) {
 
// node add/edit form
 
if (substr($form_id, -10)=='_node_form') {
   
// manually set a weight on the revision fieldset
   
$form['revision_information']['#weight'] = -100;
  }
}
?>