0

I have created a multi step form, in which I have added radio buttons dynamically by using data from the database. The radio buttons added here are not required. But still I get the following error. I have created a custom module.

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

Kindly help me resolve this issue. This is not a duplicate issue. Other issues listed have mentioned that the radios button are used as required field in that case. Please find the code added :

$opt = array(
        'f' => 'Friend or Business Associate',
        'b' => 'Brochure',
        'c' => 'Company',
        'a' => 'Another Columbia Asia Hospital',
        'ad' => 'Advertisement',
        'an' => 'Another Doctor',

);
$step1['questions']['learn_abt'] = array (
        '#type' => 'radios',
        '#title' => t ( 'In How did you first learn about the Hospital' ),
        '#options' => $opt,


);
1
  • can u add ur custom radio button code here else how do we narrow down the cause @akshata May 18 '16 at 4:44
0

I somehow fixed the issue. Normally if it is not a required field we don't need to add the following code.

'#required' => FALSE,

But adding this code fixed my issue. Please let me know if there is any better or correct way to fix this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.