2

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'];

node_submit($node);
node_save($node);

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

0

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;
      $i++;
    }

Your Answer

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

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