Look at the screenshot. On the left you can see the created_at value in the database. On the right you can see it on the screen. The years do not appear. I'm having this problem with every date widget, where the date is from a source that I just imported.
Why are the years not showing up?
Gabor Fasi answers:
The year widget's options contain a few years back and forth from the current one by default. It's just guesswork without seeing the html source, but I believe 2005 is not included in the created_at wiget's options, thus selection the default empty option.
sfWidgetFormDate has an optional `years` option, where you can specify which years you want to have it displayed.
Loban Rahman answers:
Check out the contents of configure() for sfWidgetFormDate:
$this->addOption('days', parent::generateTwoCharsRange(1, 31));
$this->addOption('months', parent::generateTwoCharsRange(1, 12));
$years = range(date('Y') - 5, date('Y') + 5);
$this->addOption('years', array_combine($years, $years));
As you can see, by default it allows all days, all months, and the previous 5 to next 5 years. All 3 field ranges can be customised with the options. So pick a range that works for you. Or, you can make it extra smart by adding a bit of custom code that, regardless of the range of years given, will always include one option for the year that is in the model (by reading $this->getObject()), so that you never get a blank year.