zendframework/zf2 — pull request #4996 by weierophinney (2013-08-21 15:26:23+00:00)
Title: BaseInputFilter->add deasn't work (Form Validation breaks since 2.2)

I have a form with one element and set it as `required` in input filter but it doesn't work because the form adds default input specifications before I set my own and merging of both doesn't work as it leaves the defaut specifications:

MyForm:

```php
class NewsletterLayoutForm extends \Zend\Form\Form
{
public function __construct()
{
parent::__construct('newsletter_layout');
$this->setInputFilter(new \Zend\InputFilter\InputFilter());
$this->addNameElement();
}

protected function addNameElement()
{
$this->add(array(
'name' => 'name',
'attributes' => array(
'type' => 'text',
),
'options' => array(
'label' => 'Name',
),
));

$this->getInputFilter()->add(array(
'required' => true,
'filters' => array(
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 255,
),
),
),
), 'name');
}
}
```

Failing Test for `BaseInputFilterTest` that shows `BaseInputFilter->add()` doesn't work as expected (and expected by `Zend\Form`):

```php
public function testAddingExistingInputWillMergeIntoExisting()
{
$filter = new InputFilter();

$foo1 = new Input('foo');
$foo1->setRequired(true);
$filter->add($foo1);

$foo2 = new Input('foo');
$foo2->setRequired(false);
$filter->add($foo2);

$this->assertFalse($filter->get('foo')->isRequired());
}
```