Le 20/04/10 à 09:00, Michel Morelli michel@ziobuddalabs.it a écrit :
All works quite fine, but, if validation fails (title not set for example), my own form_alter, validate or submit function aren't called.
Strange,
It seems normal
have you tried to add a line like
drupal_set_message("In my form_alter");
to you form_alter function ? Try in _validate and _submit, too.
Yes of course, I say that because I check it before. If validation fails, none of form_alter, validate or submit (this is logical not call submit if validate fails) are called. http://drupal.org/node/398562 http://drupal.org/node/671574
../..
$form['keywords'][$vid][$tid]['#default_value'] = $toset;
../..
Because you need to say that the menu need to be rebuild ($form_state['rebuild'] = true;) (but yuo need to make this in _validate function).
_validate function isn't called, if I add this in _after_build function, it doesn't change anything, a call to form_builder in this _after_build doesn't change anything (changes are made but not transmitted to drupal_render).
However I have see that in your code (the first) there is not set the "#default_value" in $form['keywords'][$vid][$tid] item.
It was set ;-) (see above)
My pb is why my modified form (in _after_build, I'm sure, diplaying its dump with drupal_set_message) isn't transmitted to drupal_render ?
And I don't understand why drupal render is called twice with this form (same form_build_id)...
Thanks for suggestions
(I'll look what happen with a standard nodetype as page to better understand fapi process)