Skip to content

Commit

Permalink
Merge pull request zendframework#3861 branch 'hotfix/add-getter-form-…
Browse files Browse the repository at this point in the history
…validationgroup'
  • Loading branch information
Maks3w committed Feb 22, 2013
2 parents 346a834 + ba1a804 commit 9598a97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
17 changes: 14 additions & 3 deletions library/Zend/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,10 @@ public function isValid()
$filter->setData($this->data);
$filter->setValidationGroup(InputFilterInterface::VALIDATE_ALL);

if ($this->validationGroup !== null) {
$this->prepareValidationGroup($this, $this->data, $this->validationGroup);
$filter->setValidationGroup($this->validationGroup);
$validationGroup = $this->getValidationGroup();
if ($validationGroup !== null) {
$this->prepareValidationGroup($this, $this->data, $validationGroup);
$filter->setValidationGroup($validationGroup);
}

$this->isValid = $result = $filter->isValid();
Expand Down Expand Up @@ -532,6 +533,16 @@ public function setValidationGroup()
return $this;
}

/**
* Retrieve the current validation group, if any
*
* @return null|array
*/
public function getValidationGroup()
{
return $this->validationGroup;
}

/**
* Prepare the validation group in case Collection elements were used (this function also handle the case where elements
* could have been dynamically added or removed from a collection using JavaScript)
Expand Down
12 changes: 12 additions & 0 deletions tests/ZendTest/Form/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1345,4 +1345,16 @@ public function testPrepareBindDataAllowsFilterToConvertStringToArray()
$this->form->setData($data);
$this->form->bindValues($data);
}

public function testGetValidationGroup()
{
$group = array('foo');
$this->form->setValidationGroup($group);
$this->assertEquals($group, $this->form->getValidationGroup());
}

public function testGetValidationGroupReturnsNullWhenNoneSet()
{
$this->assertNull($this->form->getValidationGroup());
}
}

0 comments on commit 9598a97

Please sign in to comment.