Drupal forms: don't forget your tree
$form['place_taxonomy']['#tree'] = TRUE; // this was so important and so easy to overlook
If you're working with or creating complex forms, and can't figure out why your, oh, 'place_taxonomy' form data isn't getting to your place_taxonomy_node_save($node, $terms) function -- for example -- even though your hook_nodeapi implementation is most definitely pointing your 'insert' and 'update' operations (or 'op's, as we at Agaric affectionately call them), you may be able to save yourself the trouble of sticking in a drupal_set_message('<pre>' . print_r($node, TRUE) . '</pre>');
to debug.
Check that you have set your tree to TRUE. Otherwise, only the last value in the chain gets passed-- $form['place_taxonomy'][1][20]
becomes merely an absurd $form['20']
.
(All the above is purely hypothetical and never happens to Agaric. We're professionals.)
Resolution
$form['base_of_complex_array']['#tree'] = TRUE;
Comments
Post new comment