Hello,

Im having problems adding values to my content_taxonomy field using drupal_execute();
For other cck fields i would use
$form_state['values']['field_myfield'][0]['value'] = $myvalue;
but for content taxonomy fields this is not working.

any suggestions?

Comments

mh86’s picture

are you using term ids for the $myvalue?
and which kind of widget are you using? the structure for autocompletes might look a bit different

loze’s picture

Im using term ids, I tried as both a string and an integer.
Im using a single value select list
The field is required on my form (if that matters)

ive tried just about every thinkable variation of the array
like
$form_state['values']['field_myfield']['value']
$form_state['values']['field_myfield']
$form_state['values']['field_myfield']['value'][0]
etc.
even tho they didnt seem right.

loze’s picture

ok, this is weird.

i still cant save the correct values to the dropdowns.

however
$form_state['values']['field_myfield'][0]['value'] = '2192';
is saving a value of '2'

the first character?

mh86’s picture

the select boxes of content taxonomy are based on the optionwidgets of cck. so it should work the same way as it does with cck select boxes.
maybe you can do some debugging?

loze’s picture

thanks mh86,
Yes it does appear that im having the same problem for all CCK select elements, this doesnt appear to be content taxonomy specific.

If i figure it out ill post back.
Ive searched on here and found some suggestions, but none seem to work for me.
so for my project right now, im going to use node_save()
it seems to work for what i need.

thanks for your time.

marqpdx’s picture

hi, i'm running into this as well.
subscribing.
thx,
m

ps -i'm now updating my content table as well as term_node to get around this.

peter törnstrand’s picture

Having the same problem. If works as expected when only one node is created per CRON-run. But if I create multiple nodes on a run I get the problem described in #3.

Here is what I found.

#416126: CCK text field select list options widget data incorrect when call drupal_execute() more than once
#260934: Static caching: when drupal_execute()ing multiple forms with same $form_id in a page request, only the first one is validated

Work around for this: http://drupal.org/node/260934#comment-1179304

TheThumbPuppy’s picture

I'm having the same problem and I have tried unsuccessfully with:
$form_state['values']['field_myfield'][0]['value']

Have you found a solution for this?

Thank you in advance

TheThumbPuppy’s picture

With the help of theme developer from the Devel module, I was able to find out the names of the Content Taxonomy form fields, which in my case were:

#name (String, 30 characters ) field_token_prod_number[value]
#name (String, 32 characters ) field_token_prod_duration[value]

I have then used the following lines:

$form_state['values']['field_token_prod_number']['value'] = $result_conversation->prod_number_tid;
$form_state['values']['field_token_prod_duration']['value'] = $result_conversation->prod_duration_tid;

drupal_execute saves now the nodes with the correct values for the Content Taxonomy fields.

I hope that these quick notes will be of some help.

magnus’s picture

Status: Active » Closed (fixed)

Please reopen issue if problem still exists.