Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize a create content form for a certain content type

Tags:

drupal

How do I customize a create content form for a certain content type. In this instance I have a CCK type, of Products but every time I create a product I use 4 fields Name, Price, Picture and dimensions.

Is there a way to slim down the create content form to just have these options? Is this what Contemplate does?

like image 802
Brian G Avatar asked Feb 04 '09 16:02

Brian G


1 Answers

You'll want to use the hook_form_alter hook.

In Drupal 6, I use this to hide most of the extraneous stuff in the node edit/add form.

function mymodule_form_alter(&$form, $form_state, $form_id) {
  // hide extraneous options in the node form for nodetype nodes
  if($form_id == 'nodetype_node_form') {
    $form['path']['#access'] = FALSE;
    $form['menu']['#access'] = FALSE;
    $form['author']['#access'] = FALSE;
    $form['options']['#access'] = FALSE;
    $form['comment_settings']['#access'] = FALSE;
    $form['revision_information']['#access'] = FALSE;
  }
}

Contemplate is for styling the node view, not the node form. I advise against it - it's far better to use node-nodetype.tpl.php files.

like image 142
ceejayoz Avatar answered Oct 15 '22 00:10

ceejayoz