Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2119 from weierophinney/hotfix/zf2-440
Browse files Browse the repository at this point in the history
Hotfix/zf2 440
  • Loading branch information
Maks3w committed Aug 6, 2012
2 parents 8840219 + 2039901 commit 2a926c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library/Zend/InputFilter/BaseInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
16 changes: 16 additions & 0 deletions tests/ZendTest/Form/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.