Take the 2-minute tour ×

I understand that I need to go down the path of hook_form_alter, however this doesn't appear to be getting me very far, initially:

hook_form_alter(&$form, &$form_state){
  switch ($form['form_id']['#value']){
    case 'partner_node_form':

DSM outputs partner_node_form and the code fires when I go to /node/add/partner, however it doesn't make the field optional, and it is still given a red asterisk.

If I submit the form, it fails, stating that the field is required, but now DSM outputs admin_block_theme_form instead, which is preventing my alter code from even running.

Obviously, I'm quite lost, please help!

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I knew that there was a solution to this ;). Found it today when I was working on something else.

Install content_taxonomy module. Once you do this you will have taxonomy as a CCK field in all the content types. Hence you can make it optional for a selected content type. You have an option to select the vocabulary and moreover you can use this like any other CCK field.

share|improve this answer
Yes I thought I might have to go down this route. I'm already using Hierarchical Select and Taxonomy Super Select on this project, I'm reluctant to add another Taxonomy Module, but I'll give it a go thanks :) –  DanH Apr 13 '11 at 10:28
define('MY_VOCABULARY', 1);

$form['taxonomy'][MY_VOCABULARY]['#required'] = 0;

it's works fine in drupal 6. what drupal version you use ?

share|improve this answer

Your Answer


