0

I created a custom module to override some fields in an exposed form created by views. One of the filters is the between filter on a number field. The between filter produces min and max fields for every field in the form. What I want to do is replace the min and max text fields with lists of integers that the user can select from. Where I am stuck at is the default value of the lists. I keep getting the following message: "An illegal choice has been detected. Please contact the site administrator." Below is a snippet from my module file:

$sale_price_min_options=array(
  'All'=>t('-Any'),
  10000=>'10000',
  20000=>'20000',
  30000=>'30000',
  40000=>'40000',
  50000=>'50000',
  60000=>'60000',
  70000=>'70000'
);


$form['field_sale_price_value']['min']=array(
          '#type' => 'select',
          '#options' => $sale_price_min_options,
          '#default_value' => "",
      );
      $form['field_sale_price_value']['max']=array(
                '#type' => 'select',
                '#options' => $sale_price_min_options,
                '#default_value' => 70000,
            );

Please let me know where did I go wrong. Many thanks in advance

1

Change 'All' to ''. The key should be blank. The default value is not matching the option list.

|improve this answer|||||
  • Thanks for your suggestion @kevin, using your approach I get the first choice as blank. What I want is have one of the items chosen by default. – redamakarem Oct 7 '16 at 16:02

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.