开发者

Symfony 1.4 Form Value change after getValues()

I've got some problem with symfony form value (i guess it's the clean value, but not so clear yet). Here's the problem :

I got a sfFormDateJQueryUI widget setup like this in my form :

$this->setWidgets(array(
          'needDate'    => new sfWidgetFormDateJQueryUI(),
        ));
$this->setValidators(array(          
 'needDate'    => new sfValidatorDate(array(
             'required' => true,
             'date_format' => '/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/',
             'date_output' => 'd/m/Y'
            )),
        ));

Then when i submit, say 26/06/2010, it turns out right in the HTTP Header (viewed via Firebug) and $request (i just print it). But after i get the value via

$formVal = $form->getValues();

the date value in $formVal["needDate"] become today's date (03/06/2010). I really don't understand, and after che开发者_StackOverflow社区cking in the API documentation it says that the getValues will return the 'cleaned' value. Is that because of it ? I don't understand what's 'clean'.

Thanks before..


Somehow I solved the problem. It turns out that the value can't validate, so when I changed the validator to:

'needDate' => new sfValidatorRegex(array(
                'pattern' => '/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/'
              ))

everything works fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜