开发者

how to check if the enddate is after the startdate in a zend form

开发者 https://www.devze.com 2022-12-27 16:52 出处:网络
I have a zend form with a start- and an endate. $form = new Zend_Form(); $form->setName($this->formName)

I have a zend form with a start- and an endate.

$form = new Zend_Form();
$form->setName($this->formName)
     ->setMethod('post');

$feStartdate = new Zend_Form_Element_Text('startdate');
$feEnddate = new Zend_Form_Element_Text('enddate');

$form->addElement开发者_StackOverflow中文版($feStartDate)
     ->addElement($feEndDate)
     ->addElement('submit', 'submit', array('label' => 'Save'));

I assume I must write a custom validator for to check this. How would this custom validator look like and how can I call it? I assume something like

$feEnddate->addValidator('dateComesAfter', $feStartDate)


Yep, custom validator, combined with Zend_Date::isLater() would be the way to go.

0

精彩评论

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