I have an exposed filter form, and its default widgets are textfields. I'd like to change them to selects based on values from database.
I have tried hook_form_alter
and hook_form_views_exposed_form_alter
, but get an error:
An illegal choice has been detected. Please contact the site administrator.
The code I used to change the widget is like this and I've tried #validate
option.
$form['field_address_province'] = array(
'#type' => 'select',
'#options' => $province_options,
'#validate' => true,
'#description' => 'Select address',
);
Edit:
Sorry for the lack of infomation.
The $province_options
is an array like
Array
(
[0] => Please Select
[6] => Area1
[7] => Area2
[2] => Area3
)