A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

How to customise the "content edit form" in Drupal

/**
* Catch the theme_node_form function, and redirect through the template api
* Allows us to customise the fields displayed on the "create content" form
*/
function phptemplate_node_form($form) {
$admin_role_id = 3;

if ((! $user->roles[ $admin_role_id ]) && ($user->uid != 1)) {
// user is not an admin, hide all the advanced fields

// Default Drupal fields
unset($form['attachments']);
unset($form['options']);
unset($form['author']);
unset($form['comment_settings']);
unset($form['revision_information']);
unset($form['menu']);
unset($form['body_field']['format']);
unset($form['path']);
//$form['format']['#title'] = 'Advanced setting: Input format'; // e.g. rename fields

// Ubercart fields
//unset($form['base']); // note: can't submit without this because display price and SKU are required
//unset($form['taxonomy']);
//unset($form['field_image_cache']);
//unset($form['google_checkout']);

// call the original function
return theme_node_form($form);
}