A simple problem with validating the form
Hamid.D - October 12, 2008 - 14:04
Hi friends,
I have a drop-down list which has 2 options.when the form is shown to user then I add more options to it by javascript.
by this way I get a validation error:("an illegal selection has been selected")
after searching for problem I found this:
"Elements with options (check boxes, radio buttons, and drop-down selection
fields) are examined to see if the selected value is actually in the original list of options
present when the form was built"(Pro drupal development book)
that is my problem,how can I solve my problem?
thanks and excuse me for english;

Solution to your problem
This is a drupal security feature
You need to put
#DANGEROUS_SKIP_CHECK to TRUE in your form element.
for eg.
$form['custom'] = array('#type' => 'select',
'#title' => t('Custom visibility settings'),
'#options' => $options,
'#DANGEROUS_SKIP_CHECK' => true,
'#default_value' => $default,
);
I use
I use "'#DANGEROUS_SKIP_CHECK' => true" but still gives me the same error.
are you sure that it works in drupal 6?
thanks/
----------
Hamid