I am writing a new module that makes extensive use of hook_nodeapi to attach an arbitrary number of images to an existing nodetype. The code works fine except for one *very* frustrating problem that I can't for the life of me figure out.
I modify the existing forms using hook_form_alter().
If I enter data into my new fields, and click submit, everything works fine.
If I click preview, my problems begin:
All of the form elements are rendered correctly on the HTML form, but if I click preview or submit again, their values are not added to $node and my application fails.
The form element is set up in hook_form_alter() as follows:
$form['nodeimages']['nodeimage']['#tree'] = TRUE;
$form['nodeimages']['nodeimage']['new']['caption'] = array(
'#type' => 'textfield',
'#title' => t('Caption'),
'#default_value' => $node->nodeimage['new']['caption'],
'#size' => 40,
'#maxlength' => 255);
I don't know if I am missing something important here, but at what point to the values in $_POST get added to $node (if ever)? If they don't, how do I go about accessing them from within the Drupal framework.
I have scoured the forums and looked at some of the other modules that ship with 4.7, but I can't seem to find an obvious cause/solution.
If anyone can point out what I am missing, I will really appreciate it.