0

I've a field organization_name which is term reference with unlimited values. Whenever somebody saves the node I want to attach a few more terms in this field.

I've tried doing using hook_presave and also using submit handler of Forms API.

But the problem is that they both expect the term to be filled with plenty other values as below. Where do I get those values? From taxonomy_term_load ?

This is the dsm out of the form_state array in the form submit handler.

enter image description here

  • Have you thought about using rules? – Daniel Harper Oct 28 '13 at 16:59
0

The only place you need to add values in your hook_form_alter() is the $form_state['values'] array. In there you should only see the tid value, not the whole term entity.

Alternatively, you can use the Rules module

  • I did not ask this. I'm asking what values do I need to fill in tid array in form_state for example: tid, vid, name etc. Or can I simply attach the term object(converted to array) as is? – user5858 Oct 29 '13 at 4:09
  • Is your dpm() in your question from $form_state['values']? What I'm saying in my answer is that you should not see all that stuff there, but only the tid. – goron Oct 30 '13 at 6:40
  • No but I'm seeing all those stuff for all my term reference fields. – user5858 Oct 30 '13 at 8:39
  • Again, the only place you need to add to in order to add field values is $form_state['values']. Since none of that other stuff appears in there, you don't need to worry about it. Simply add your tids to the field's value array within $form_state['values']. – goron Oct 31 '13 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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