Permalink
Browse files

Merge pull request #2119 from weierophinney/hotfix/zf2-440

Hotfix/zf2 440
  • Loading branch information...
2 parents 8840219 + 2039901 commit 2a926c8b02587e5ebdfd674e036fca5c82b97b05 @Maks3w Maks3w committed Aug 6, 2012
Showing with 20 additions and 2 deletions.
  1. +4 −2 library/Zend/InputFilter/BaseInputFilter.php
  2. +16 −0 tests/ZendTest/Form/FormTest.php
@@ -157,10 +157,12 @@ public function isValid()
$valid = true;
$inputs = $this->validationGroup ?: array_keys($this->inputs);
- //var_dump($inputs);
foreach ($inputs as $name) {
$input = $this->inputs[$name];
- if (!array_key_exists($name, $this->data) || (is_string($this->data[$name]) && strlen($this->data[$name]) === 0)) {
+ if (!array_key_exists($name, $this->data)
+ || (null === $this->data[$name])
+ || (is_string($this->data[$name]) && strlen($this->data[$name]) === 0)
+ ) {
if($input instanceof InputInterface) {
// - test if input is required
if (!$input->isRequired()) {
@@ -992,4 +992,20 @@ public function testExtractDataHydratorStrategy()
$this->assertEquals('AAA', $entities[0]->getField2());
$this->assertEquals('CCC', $entities[1]->getField2());
}
+
+ public function testSetDataWithNullValues()
+ {
+ $this->populateForm();
+
+ $set = array(
+ 'foo' => null,
+ 'bar' => 'always valid',
+ 'foobar' => array(
+ 'foo' => 'abcde',
+ 'bar' => 'always valid',
+ ),
+ );
+ $this->form->setData($set);
+ $this->assertTrue($this->form->isValid());
+ }
}

0 comments on commit 2a926c8

Please sign in to comment.