I have a content type with a number of text fields and a field linked to a taxonomy vocabulary with about a dozen terms.

I have successfully developed code using the Form API to insert data from my custom form into my node using node_submit for the text fields. A sniped of the code I use is for the text fields is:

$node->field_s_phone[$node->language][0]['value'] = $form_state['values']['phone']; 
$node->field_s_email[$node->language][0]['value'] = $form_state['values']['email'];


I would like to implement a single set of checkboxes of my vocabulary terms on the custom form, then pass the values using node_submit in a similar fashion to the text fields (sort of like):

$node->field_catagories[$node->language][0]['value'] = $form_state['values']['catagories']; 

I would be grateful for any thoughts or insight.

Thanks, Bill

1 Answer 1


Try this, if I completely understood you, this should help.

    $i = 0;
    foreach($form_state['values']['catagories'] as $tid) {
      $node->field_catagories[$node->language][$i]['tid'] = $tid;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.