views:

193

answers:

2
  $form_state['values']['field_prx_mp3_labels'][0][value] = $mp3_labels;  
  $form_state['values']['taxonomy'][0][value] = array('tags'=>array('1'=>'Music'));  
  $errs = drupal_execute('prx_content_node_form', $form_state, (object) $nodeTmp);  

This is a Drupal 6 site. I am using drupal_execute to create a node programatically. The first line is working for field_prx_mp3_labels. The second (for taxonomy) is not.

Here is what my select on the node add for my cck looks like:

<select name="taxonomy[2][]" multiple="multiple"  class="form-select" id="edit-taxonomy-2"  size="9"><option value="">- None -</option><option value="5">Music</option><option value="6">-Rock/Pop</option><option value="7">-Jazz/Blues</option><option value="8">-Classical</option><option value="9">-Music Documentaries</option><option value="10">-Festivals/Concerts</option><option value="11">Arts</option><option value="19">-Literature</option><option value="12">Nature</option><option value="13">History</option><option value="15">-Music</option><option value="14">Culture</option><option value="17">-American Indian</option><option value="18">-Latino</option><option value="16">-Youth Perspective</option></select> 

I have tried many many variations for line 2 (relating to the taxonomy).

This comment seemed close but it hasn't worked for me: http://drupal.org/node/178506#comment-1155576

Thanks!

+1  A: 

Doesn't [value] have to be in quotes?

And did you try this:

$form_state['values']['taxonomy'] = array('tags'=>array('1'=>'Music'));
Kevin
I tried it in quotes and no luck. The first line works and there aren't quotes there. Thanks though!
rdurbin
Updated my answer. Taxonomy isn't a CCK field and hence would not need [index][value] attached like you find CCK fields do.
Kevin
Hmm. I tried that as well and didn't have any luck. Good point about not being part of CCK.
rdurbin
A: 

I ended up doing it a different way. Basically I run drupal_execute to push the CCK content in Drupal. Right after that runs I query the DB to get the ID of the node I just inserted. I then take that ID and run a loop that inserts the taxonomy relationships directly into the term_node table.

The possible problem this causes is the taxonomy information isn't available during the drupal_execute. That means if you are relying on the taxonomy for part of your pathauto/alias rules the taxonomy won't yet be available.

rdurbin

related questions