[support] [solved] how to preserve current checkbox values if validation fails

Daniel Caillibaud ml at lairdutemps.org
Wed Apr 21 16:38:02 UTC 2010


Le 19/04/10 à 20:21, Daniel Caillibaud <ml at lairdutemps.org> a écrit :

> Hi,
> 
> In a custom nodetype, I have a fieldset $form['keywords'] with stuff filled by ajax calls, e.g.
> 
> $form['keywords'][$vid][$tid]['#type'] = 'checkbox';
> $form['keywords'][$vid][$tid]['#value'] = $tid;
> $form['keywords'][$vid][$tid]['#name'] = 'taxonomy[' .$vid .'][' .$tid .']';
> 
> All works quite fine, but, if validation fails (title not set for example), my own form_alter, validate or submit function
> aren't called.

_validate is called, but can't do anything directly ($form is here just for reading and drupal_render doesn't take care about
$form_state). form_set_value should be a solution.

I make my changes in _after_build, BUT I first forgot to add a 
unset($form['keywords']['#after_build_done']);
in ajax callback ajax, after form_builder and before form_set_cache...

-- 
Daniel


More information about the support mailing list