An illegal choice has been detected. Please contact the site administrator.
| Project: | Active Select |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Hi,
I used Active Select module to display a hierarchical data to enable select landmark detail ( Province > City > Sub City > District > Metro Station ) , I used taxonomy module ( with some database addition ) to store this hierarchical database structure.
Now on the form, I have a select fields for all those fields linked together with Active Select . My requirement was I need to display the landmark field where as it's value should be the id of the term. So I did the following on my callback function :
function venues_getLandmark($source='', $targets='', $string='', $extra = NULL)
{
if (empty($source) || empty($targets) || empty($string)) {
exit();
}
$targets = explode(',', $targets);
$output = array();
//var_dump($string);
$array = activeselect_explode_values($string);
foreach ($targets as $target) {
$options = array();
$first_element = TRUE;
foreach ($array as $key => $value) {
$vocabulary = db_query("SELECT term_data.name, term_data.tid FROM {term_data},{term_hierarchy} WHERE term_data.tid=term_hierarchy.tid and term_hierarchy.parent=".$key." ORDER BY name");
while ($term = db_fetch_object($vocabulary)) {
$options[$term->tid]['value'] = $term->name;
}
}
$multiple = FALSE;
$output[$target] = array('options' => $options, 'multiple' => $multiple);
}
activeselect_set_header_nocache();
print drupal_to_js($output);
exit();
}Now, After making the choice when I submit form , I get the error - " An illegal choice has been detected. Please contact the site administrator. " on all of those fields .
Can you please assists me.
Best Regards
Kaushal

#1
In activeselect definition add '#DANGEROUS_SKIP_CHECK'=>true, to array
example:
$form['example'] = array(
'#type' => 'activeselect',
'#options' => $options,
'#title' => t('Example'),
'#DANGEROUS_SKIP_CHECK'=>true
);
#2
Warning:
You should only use the #DANGEROUS_SKIP_CHECK Form API property if you're particularly evil. For more information on this, the most evil of Form API properties, see #DANGEROUS_SKIP_CHECK: the most evil of the Form API properties | groups.drupal.org.
#3
Hi people,
After upgrading to D6.13, I've been dealing with the same error on some client's websites. I've been able so solve it and wrote my solution down at: http://www.halecommunications.be/blog/?p=88
Hope I can be of any assistance! Please note that this solution has only been tested on Drupal 6 platforms...
greets,
Kim