[development] decoupling form validation from error reporting and "actions" OR different use case for DANGEROUS_SKIP_CHECK
Roberto Gerola
roberto.gerola at speedtech.it
Wed May 21 13:47:58 UTC 2008
On Wed, 2008-05-21 at 11:44 +0200, Ivan Sergio Borgonovo wrote:
> I'd consider *possible* that a user open another browser window
> and change the previous choices while it is in the middle of the
> process. Since the forms are dynamically built, when a $form is
> "regenerated" for submission it may be different from the one that was
> shown to the user.
>
> At this point form validation kick in and says
> "An illegal choice has been detected..."
Hi.
I encountered the same issue working with dependent drop downs
filled by Ajax and JS code.
Here there is the technique I'm using in one of my projects.
Not sure it is the best approach, but it is the only one
I was able to implement when I ported my code from D5 to D6.
Hope this helps.
Roberto
***
function storm_dependent_select_process($form, $edit, $form_state,
$complete_form) {
unset($form['#needs_validation']);
return $form;
}
$form['group1']['project_nid'] = array(
'#type' => 'select',
'#title' => t('Project'),
'#default_value' => $node->project_nid,
'#options' => array(0 => '-') + $projects,
'#process' => array('storm_dependent_select_process'),
'#required' => true,
'#attributes' => array('onchange' => "stormtask_project_tasks(this, 'edit-task-nid', true, '-')"),
);
More information about the development
mailing list