The situation is this:
- I have two module-defined content types, "art shows" and "artists".
- Each show is associated to an undefined number of artists. The associations are stored in a special join table, "show-artist".
- On creation of a new show, there's only one 'artist' autocomplete field (the artist list is really long). I wrote a nice JQuery script that adds more fields on the fly when the user clicks a button. They are called artist_0, artist_1, artist_2, etc.
- After submission, hook_validate grabs these new fields directly from $_POST. It checks wether the names indeed exist in table "artist", and stores their nids in a variable that is passed to hook_insert (or update) via form_set_value. If a name is not on the table, it prints an error with form_set_error.
- hook_insert and hook_update write the associations to the join table, and hook_load retrieves them again when the node is viewed or edited.
- Everything works quite nicely as long as all values pass validation. But when there's an error, and the form is rendered again with the corresponding message at the top, all the new fields are lost. I'm not able to pass any data from hook_validate to hook_form.
- I tried modifying the $node object. Doesn't work. Tried creating new fields with form_set_value. Doesn't work.