Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release'

  • Loading branch information...
commit 639649396585a5ba197624661e457e82a6447c67 2 parents 2ebfc42 + 2f64c56
Matthew Weier O'Phinney weierophinney authored
Showing with 18 additions and 6 deletions.
  1. +10 −6 library/Zend/Form/Form.php
  2. +8 −0 tests/ZendTest/Form/FormTest.php
16 library/Zend/Form/Form.php
View
@@ -628,15 +628,19 @@ public function attachInputFilterDefaults(InputFilterInterface $inputFilter, Fie
$formFactory = $this->getFormFactory();
$inputFactory = $formFactory->getInputFilterFactory();
foreach ($fieldset->getElements() as $element) {
+ $name = $element->getName();
+
if (!$element instanceof InputProviderInterface) {
- // only interested in the element if it provides input information
- continue;
+ if ($inputFilter->has($name)) {
+ continue;
+ }
+ // Create a new empty default input for this element
+ $spec = array('name' => $name, 'required' => false);
+ } else {
+ // Create an input based on the specification returned from the element
+ $spec = $element->getInputSpecification();
}
- $name = $element->getName();
-
- // Create an input based on the specification returned from the element
- $spec = $element->getInputSpecification();
$input = $inputFactory->createInput($spec);
$inputFilter->add($input, $name);
}
8 tests/ZendTest/Form/FormTest.php
View
@@ -159,6 +159,14 @@ public function testCanComposeAnInputFilter()
$this->assertSame($filter, $this->form->getInputFilter());
}
+ public function testDefaultNonRequiredInputFilterIsSet()
+ {
+ $this->form->add(new Element('foo'));
+ $inputFilter = $this->form->getInputFilter();
+ $fooInput = $inputFilter->get('foo');
+ $this->assertFalse($fooInput->isRequired());
+ }
+
public function testCallingIsValidRaisesExceptionIfNoDataSet()
{
$this->setExpectedException('Zend\Form\Exception\DomainException');
Please sign in to comment.
Something went wrong with that request. Please try again.