An illegal choice has been detected when I submit my webform module I am getting this error 


  An illegal choice has been detected 


when I am submitting my webform and that is happening only on the select fields , as i read on the internet it suppose to have default value but i don't know how to put it in the code I am editing my webform-form-16.tpl and I have the code like this.

$form['submitted']['material']['#title']='';
$form['submitted']['material']['#prefix']='&lt;div class="row"&gt;&lt;label&gt;Material:&lt;/label&gt;&lt;br&gt;&lt;span class="select" id="selectselect"&gt;&amp;nbsp;&lt;/span&gt;';
$form['submitted']['material']['#options'] = array('Steel'=&gt;'Steel','Yellow Gold'=&gt;'Yellow Gold','White Gold'=&gt;'White Gold','Steel and Yellow Gold'=&gt;'Steel and Yellow Gold');
$form['submitted']['material']['#suffix']='&lt;/div&gt;';
Editing webform-form-**.tpl or any template file is designed to alter the theme or display of the webform. It seems you are having issue with the forms content, specifically default values.

If you are using the Form API to create your form in your own module, you will need to declare it as described in the FAPI documentation.

&lt;?php
  $form['selected'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; t('Selected'),
    '#options' =&gt; array(
      0 =&gt; t('No'),
      1 =&gt; t('Yes'),
    ),
    '#default_value' =&gt; $category['selected'],
    '#description' =&gt; t('Set this to &lt;em&gt;Yes&lt;/em&gt; if you would like this category to be selected by default.'),
  );
?&gt;


The error that you are getting tends to occur when form elements are submitted that were not defined in the original form. And by the look of your template edit, that could easily be the case.

Check out your log at Administer > Logs > Recent log entries to see what is causing the error.

To get an empty entry submitted from the select options force the 'empty option' form declaration. Works like a treat.

'#empty_option'=&gt;t('- Select -'),


Good luck.
xK