Transform textinput into select-field I'm trying to transform my textinput into a select-field but I keep stumbling upon An illegal choice has been detected-error.

What I try in my hook_form_alteris this:

$form['distance']['search_distance']['#type'] = 'select';
$form['distance']['search_distance']['#options'] = drupal_map_assoc(array(100 =&gt; '100 km', 200 =&gt; '200 km'));


It looks like he's doesn't like strings to be in the select list, although, the value of the input is an integer...

How can I make this input field accept my modifications?
I don't know if this is causing the error, but you're using drupal_map_assoc() wrong...

The point of that function is to take a linear array and convert it to an associative array with the values of the given array as associated keys. e.g. 

$form['distance']['search_distance']['#options'] = drupal_map_assoc(array(100, 200, 300));


I kind of suspect what you're meaning to do is this:

$form['distance']['search_distance']['#options'] = array(100 =&gt; '100 km', 200 =&gt; '200 km');


Your array is already associative, no need to try making it associative all over again :)