An illegal choice has been detected. Please contact the site administrator.

kaushal - June 22, 2007 - 06:44
Project:Active Select
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

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

exodusx - September 21, 2007 - 13:33

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

chOP - June 13, 2008 - 01:45

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.

 
 

Drupal is a registered trademark of Dries Buytaert.