Currently when we use default date field with widget select list, it shows like 3 drop-downs with Year, month and date. Is there any way to make it as one drop down. I need to display few dates from today's date( may be 5 or 10 dates).

My date field should look like below section. Format can be different but will display whole date in one select list.

September 19 2014
September 20 2014
September 21 2014
  • 1
    Why? Scrolling to 2010 would be hell, and 30 days x 12 months x 10 years means 3600 positions. A little hell for your user's browser. Each date is about 16 bytes, so we are talking about 56 KB data for one field. With <option> tags markup and all that, make it about 128 KB. Really? Category listing of a page I currently work on has 35,5 KB of syntax. And it is a pretty complicated one, with filters etc.
    – Mołot
    Sep 19, 2014 at 7:36
  • 1
    I mean, if you only need few dates from now, it's still risky. Forget a limit somewhere, and your site have a problem. Disabling year and month would be safer, if less convenient. I'm not saying you not to do this, I just wanted to make sure you know what you are risking by doing it.
    – Mołot
    Sep 19, 2014 at 7:47
  • 1
    @Mołot I think the case is valid enough look at the scenario of booking tickets where you have 3-5 days date or any e-paper website where you can read last 5-10 days newspaper as well. Selecting three fields for a user will be cumbersome and the user want to remove that complexity I think. Applying limit somewhere in PHP code will not put user at risk anyhow. Sep 19, 2014 at 8:03
  • 1
    @AshishBairagi I actually want the similar scenario of having 3-10 days. So selecting the date from 3 drop downs is not that much user friendly. Thats why I am trying to get in in a single selection list.
    – Aswini K
    Sep 19, 2014 at 8:11
  • 1
    Where will the valid date values be stored? I think I could formulate a solution for you given that information. Sep 19, 2014 at 12:43

1 Answer 1


I would recommend replacing the date field with text box and add a date pop to allow certain dates. This could be easily done by hook_form_alter in your custom module. See below:

     * Implements hook_form_alter().
    function yourmodule_form_alter(&$form, $form_state, $form_id) {
      switch($form_id) {
        case 'your_form_id':
          $form['yourfield']['#type'] = 'date_popup';
          $form['yourfield']['#date_format'] = 'd/m/Y';
          $form['yourfield']['#datepicker_options'] = array('minDate' => '-15D', 'maxDate' => '-1D');
          $form['yourfield']['#readonly'] = TRUE;

You will need the Date module enabled before you can use this. Let me know how you go..

  • 1
    Thanks for your reply. Actually I have seen this method before, but my requirement is to display it as select list instead of calender. Is there any way to do it.
    – Aswini K
    Sep 19, 2014 at 6:45
  • 1
    Are you looking to make 3 select lists; ie day, month,year. If its just one select list wouldn't that be a bit mental !
    – Deejay
    Sep 19, 2014 at 7:25

Your Answer

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

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