Le 20/04/10 à 11:49, Daniel Caillibaud ml@lairdutemps.org a écrit :
(I'll look what happen with a standard nodetype as page to better understand fapi process)
Fapi process is quite clear http://drupal.org/node/165104, but if _validate functions are called, when a previous validation fails (no title), changes made there on form or form_state are ignored then by drupal_render :-(
to test
function mymodule_form_alter(&$form, &$form_state, $form_id) { ... else if($form_id == 'page_node_form') { $form['#after_build'][] = '_test_after_build'; $form['#validate'][] = '_test_validate'; $form['#submit'][] = '_test_submit'; } }
function _test_validate(&$form, &$form_state) { drupal_set_message('_test_validate with build_id=' .$form['#build_id']); $form['body']['#value'] = 'My new body modified in _test_validate on form'; $form_state['values']['body'] = 'My new body modified in _test_validate via form_state'; $form['title']['#default_value'] = 'My new modified title in _test_validate'; if ($errors = form_get_errors()) { // this is executed when title validation fails drupal_set_message(edulibre_get_dump($errors, 'errors already fired in _test_validate')); } drupal_set_message(edulibre_get_dump($form, 'form in _test_validate')); drupal_set_message(edulibre_get_dump($form_state, 'form_state in _test_validate')); return $form; }
But then, in drupal_render (and of course on screen), we have the $form in its state before our _test_validate :-/