Search code examples
smarty

How to add the default value to the smarty date dropdown?


I am creating a date dropdown using smarty syntax which will display only the years.

It is showing perfectly with current year being selected.

But I want to show a text e.g. "Select Year" with value=' ' and on clicking it will show me the rest of years in the dropdown to select.

Could anyone suggest how to do it in smarty ?

Below is my code..

{html_select_date prefix="from" display_days=false display_months=false start_year=-20 month_extra='id="fromMonth"' year_extra='id="fromYear"'}  

Thank you.


Solution

  • If you're using Smarty 3, just add two parameters more to the function:

    year_empty="Select year" time=null