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 Answer 1

1

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

1
  • 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. Oct 7, 2016 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.