Last active
August 29, 2015 13:56
-
-
Save Gounlaf/9204709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function testZfIssue4619Action() | |
{ | |
$form = new \Application\Form\Issue4619(); | |
$form->setData(array('testDateTime' => 'asdf')); | |
// false | |
Debug::dump($form->isValid()); | |
// 3 validators : Zend\Validator\NotEmpty, Zend\Validator\Date, Zend\Validator\DateStep | |
Debug::dump($form->getInputFilter()->get('testDateTime')->getValidatorChain()->getValidators()); | |
$form = new \Application\Form\Issue4619(); | |
$form->getInputFilter()->get('testDateTime')->setRequired(true); | |
$form->setData(array('testDateTime' => 'asdf')); | |
// false | |
Debug::dump($form->isValid()); | |
// 3 validators : Zend\Validator\NotEmpty, Zend\Validator\Date, Zend\Validator\DateStep | |
Debug::dump($form->getInputFilter()->get('testDateTime')->getValidatorChain()->getValidators()); | |
$form = new \Application\Form\Issue4619(); | |
$form->getInputFilter()->get('testDateTime')->setRequired(false); | |
$form->setData(array('testDateTime' => 'asdf')); | |
// false | |
Debug::dump($form->isValid()); | |
// 3 validators : Zend\Validator\NotEmpty, Zend\Validator\Date, Zend\Validator\DateStep | |
Debug::dump($form->getInputFilter()->get('testDateTime')->getValidatorChain()->getValidators()); | |
$form = new \Application\Form\Issue4619(); | |
$form->setInputFilter(new \Application\Form\IssueFilter4619()); | |
$form->setData(array('testDateTime' => 'asdf')); | |
// true -> not correct | |
Debug::dump($form->isValid()); | |
// 1 validator only : Zend\Validator\NotEmpty | |
Debug::dump($form->getInputFilter()->get('testDateTime')->getValidatorChain()->getValidators()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Form; | |
class Issue4619 extends \Zend\Form\Form | |
{ | |
public function __construct($name = null, $options = array()) | |
{ | |
parent::__construct($name, $options); | |
$this->add(new \Zend\Form\Element\DateTime('testDateTime', array( | |
'label' => 'Test datetime' | |
))); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Form; | |
class IssueFilter4619 extends \Zend\InputFilter\InputFilter | |
{ | |
public function __construct() | |
{ | |
$testDateTime = new \Zend\InputFilter\Input('testDateTime'); | |
$testDateTime->setRequired(true); | |
$this->add($testDateTime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment