Ask your Symfony questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

I still can not get years to appear in date widget Symfony


I thought I had this fixed, but I guess not.

[[LINK href=""]]See my previous question. [[/LINK]]

Symfony 1.4 and Doctrine.

In the database I have fields/dates like this:

date_received: 1994-04-06

When I previously asked about this, it was suggested that I needed to have more years appear in the date/year field, so I have this in the form class:

$years = range(date('Y') - 50, date('Y') + 5);
$this->widgetSchema['date_received'] = new sfWidgetFormDate(array(
'default' => time(),
'years' => $years

This causes the year select box to list every year back to 1961.

And yet, check out the attached screenshot. The year still fails to appear. What else might be wrong?


Strange. I hit the save button on the form, and now the date in the database is:


Answers (1)


José Nahuel Cuesta Luengo answers:

The problem is that $years should be an associative array. Try:

$years = range(date('Y') - 50, date('Y') + 5);
$years = array_combine($years, $years);