Validating a date with symfony using sfValidatorSchema

Posted by aaronfalloon on Stack Overflow See other posts from Stack Overflow or by aaronfalloon
Published on 2010-02-21T11:28:32Z Indexed on 2010/06/02 23:54 UTC
Read the original article Hit count: 146

Filed under:
|

I'm using the following widget to allow a user to input a date

$this->widgetSchema['first_registration'] = new sfWidgetFormDate(array(
  'format' => '%month%/%year%',
  'years' => range(date('Y', time()) - 15, date('Y', time()) + 15)
));

The default format for a date using this widget is %month%/%day%/%year% and so that's what the default validator for this widget checks for. However, I've attempted to alter the validator...

$this->validatorSchema['first_registration'] = new sfValidatorDate(array(
  'date_format' => '%month%/%year%',
  'with_time' => false
));

This isn't working and I'm still getting an invalid error. Does anybody know why?

© Stack Overflow or respective owner

Related posts about php

Related posts about symfony