Ask your Symfony questions! Pay money and get answers fast! (more info)

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

  • SOLVED

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

[[LINK href="http://www.symfonyexperts.com/question/show/id/188"]]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?



[UPDATE]

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

0033-04-06

Answers (1)

2011-03-14

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);