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

Commit

Permalink
Merge branch 'hotfix/4451'
Browse files Browse the repository at this point in the history
Close #4451
  • Loading branch information
weierophinney committed May 9, 2013
2 parents b6bb434 + a88429b commit 2e22109
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/Zend/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie
$formFactory = $this->getFormFactory();
$inputFactory = $formFactory->getInputFilterFactory();

if ($this instanceof InputFilterProviderInterface) {
foreach ($this->getInputFilterSpecification() as $name => $spec) {
if ($fieldset === $this && $fieldset instanceof InputFilterProviderInterface) {
foreach ($fieldset->getInputFilterSpecification() as $name => $spec) {
$input = $inputFactory->createInput($spec);
$inputFilter->add($input, $name);
}
Expand Down
9 changes: 9 additions & 0 deletions tests/ZendTest/Form/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ public function testInputProviderInterfaceAddsInputFilters()
$this->assertTrue($fooInput->isRequired());
}

public function testInputProviderInterfaceAddsInputFiltersOnlyForSelf()
{
$form = new TestAsset\InputFilterProviderWithFieldset();

$inputFilter = $form->getInputFilter();
$fieldsetInputFilter = $inputFilter->get('basic_fieldset');
$this->assertFalse($fieldsetInputFilter->has('foo'));
}

public function testCallingIsValidRaisesExceptionIfNoDataSet()
{
$this->setExpectedException('Zend\Form\Exception\DomainException');
Expand Down
40 changes: 40 additions & 0 deletions tests/ZendTest/Form/TestAsset/InputFilterProviderWithFieldset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Form
*/

namespace ZendTest\Form\TestAsset;

use Zend\Form\Form;
use Zend\InputFilter\InputFilterProviderInterface;

class InputFilterProviderWithFieldset extends Form implements InputFilterProviderInterface
{
public function __construct($name = null, $options = array())
{
parent::__construct($name, $options);

$this->add(array(
'name' => 'foo',
'options' => array(
'label' => 'Foo'
),
));

$this->add(new BasicFieldset());
}

public function getInputFilterSpecification()
{
return array(
'foo' => array(
'required' => true,
)
);
}
}

0 comments on commit 2e22109

Please sign in to comment.