On Sun, Oct 17, 2010 at 4:28 PM, Paul Frields <stickster(a)gmail.com> wrote:
[...snip...]
What took me a while was figuring out that CCK content types have a
different array structure than the standard content types. In regular
Drupal content types, you can set a value with:
$form_state['values']['field_name'] = "New stuff";
However, the structure of CCK field means that you have to do some
fancier referencing:
$form_state['values']['field_name'][0]['value'] = "New
stuff";
When I tried this at first and found it worked, I was worried that
type of referencing was somehow weird, but it turns out it was in fact
correct.
I didn't quite state this right, so ignore the code snippets above.
I'm not setting values *in* a CCK content field, I'm referring to it
to set a value in a standard field, i.e.:
$newtitle = 'FWN ' .
$form_state['values']['field_issue'][0]['value'] . ' - '
.
$form_state['values']['field_beat'][0]['value'];
form_set_value($form['title'], $newtitle, $form_state);
The snippets in the original email above might or might not work
depending on when they're called in the form's travels. But that's
irrelevant to what we want, because we don't have to set them after
the user enters stuff. We're just using their content to fill in the
standard "title" field.
Paul