<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Arial">Well, I figured out the answer to my
question by looking in the code for the _form_validate() function in
form.inc.&nbsp; For those interested in the resolution, I hadn't unset the
$form['nice_menus_number']['#options'] setting in the form, so it was
still using the items in the select list as validation parameters.&nbsp;
Once I added this line<br>
<br>
unset($form[</font></font><font size="-1"><font face="Arial">$form['nice_menus_number']['#options'])<br>
<br>
to my form alter function, it worked just as I wanted.<br>
<br>
Steve<br>
</font></font><br>
-------- Original Message --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
 cellspacing="0">
  <tbody>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">Subject: </th>
      <td>"Illegal Choice" Error When Changing Select List to Text Field</td>
    </tr>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">Date: </th>
      <td>Wed, 16 Apr 2008 13:42:37 -0700</td>
    </tr>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">From: </th>
      <td>Steve Edwards <a class="moz-txt-link-rfc2396E" href="mailto:killshot91@comcast.net">&lt;killshot91@comcast.net&gt;</a></td>
    </tr>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">To: </th>
      <td><a class="moz-txt-link-abbreviated" href="mailto:support@drupal.org">support@drupal.org</a></td>
    </tr>
  </tbody>
</table>
<br>
<br>
<font size="-1"><font face="Arial">I'm using the Nice Menus module, and
I would like to be able to have more than the 10 menus allowed by the
module.&nbsp; This limit is set by a hardcoded select list on the admin
settings page for the module.&nbsp; I want to modify the form by changing
the select list to a text field so that an arbitrary number of menus
can be selected.&nbsp; To do this, I'm using hook_form_alter() to modify the
nice_menus_number field in the nice_menus_admin_settings form.&nbsp; First
here is the form code in the module<br>
<br>
/**<br>
&nbsp;* Settings form as implemented by hook_menu<br>
&nbsp;*/<br>
function nice_menus_admin_settings() {<br>
&nbsp; $form['nice_menus_number'] = array(<br>
&nbsp;&nbsp;&nbsp; '#type' =&gt; 'select',<br>
&nbsp;&nbsp;&nbsp; '#title' =&gt; t('Number of Nice Menus'),<br>
&nbsp;&nbsp;&nbsp; '#description' =&gt; t('The total number of independent nice menus
(blocks) you want.'),<br>
&nbsp;&nbsp;&nbsp; '#default_value' =&gt; variable_get('nice_menus_number', '2'),<br>
&nbsp;&nbsp;&nbsp; '#options' =&gt; drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10)),<br>
&nbsp; );<br>
<br>
&nbsp; return system_settings_form($form);<br>
}<br>
<br>
and here is my form alter function:<br>
<br>
function cwl_form_alter($form_id, &amp;$form) {<br>
&nbsp; switch ($form_id) {<br>
&nbsp;&nbsp;&nbsp; &nbsp; case 'nice_menus_admin_settings':<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; $form['nice_menus_number']['#type'] = 'textfield';<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; $form['nice_menus_number']['#size'] = 2;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
<br>
</font></font><br>
<font size="-1"><font face="Arial">This works in that it changes the
field type to a text field, and the value attribute is the value in the
nice_menus_number variable.&nbsp; This works fine as long as I select a
value of 10 or less.&nbsp; However, if I select a value higher than 10, I
get an error that says "</font></font>
<font face="Arial">An illegal choice has been detected. Please contact
the site administrator</font>."<br>
<br>
But, if I change my function to also use a select list, like this:<br>
<br>
function cwl_form_alter($form_id, &amp;$form) {<br>
&nbsp; switch ($form_id) {<br>
&nbsp;&nbsp;&nbsp; &nbsp; case 'nice_menus_admin_settings':<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $form['nice_menus_number']['#options'] =
drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15));<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
<br>
<font face="Arial">it works fine, and I can select a value higher than
10.&nbsp; Since it's using the default system_settings_form() function,
there isn't a maximum value set somewhere.&nbsp; Plus, the default value is
being set correctly when the form is initially displayed.&nbsp; Can anybody
explain why a select list works, but a text field doesn't?<br>
<br>
Thanks.<br>
<br>
Steve</font><br>
<br>
</body>
</html>