On Fri, Aug 23, 2013 at 3:27 AM, Wim Kumpen <[email protected]> wrote:
> Just checking if someone has the same problem after upgrading from 2.2.2 to
> 2.2.3.
> I have a form with validation. After upgrading, the not required fields, are
> suddenly required.
After some discussion with Michael Gallego and tracking down what is
happening under the hood, this is what I discovered:
- Prior to 2.2.3, the `setPreferFormInputFilter()` flag didn't really
do anything, though it was supposed to. The reason it didn't really do
anything is because the order of operations in
`attachInputFilterDefaults()` was incorrect, and was merging inputs
too soon. This had necessitated a strange situation in
`Zend\InputFilter\BaseInputFilter::add()` wherein the old input was
being merged to the new one, and then the new one placed in the input
filter...
- Which was clearly wrong, because it meant that flags and settings in
the new input were getting overwritten by the old ones. For this
reason, issue #4996 was created.
- In fixing #4996, I corrected the behavior in
`attachInputFilterDefaults()`, which now means that you need to call
`setPreferFormInputFilter()` and pass it a boolean `true` if you are
defining forms via configuration and/or using fieldsets or elements
that implement `InputFilterProviderInterface` and/or
`InputProviderInterface`.
So, the way you can get the pre-2.2.3 behavior is to simply do this:
$form->setPreferFormInputFilter(true);
The question I have to everyone is: should that flag be set to true by
default? And, if so, should this be done for an immediate 2.2.4
release, should it wait for the regular 2.2.4 release (third Wednesday
in September), or wait for 2.3.0?
Thoughts?
> Just a part of the code:
>
>
> $this->inputFilter = new InputFilter();
> $factory = new InputFactory();
>
> $this->inputFilter->add(
> $factory->createInput(
> array(
> 'name' => 'website',
> 'required' => false,
> 'filters' => array(
> array('name' => 'StripTags'),
> ),
> 'validators' => array(
> array(
> 'name' => 'Uri',
> 'options' => array(
> 'uriHandler' => "\Zend\Uri\Http",
> 'messages' => array(
> Uri::NOT_URI => "The input does not
> appear to be a valid Url",
> )
> )
> )
> )
> )
> )
> );
>
>
> I found something in the 'Form' class, 'attachInputFilterDefaults' method.
> Fields like 'email', 'url' are instances of InputProviderInterface and then
> he gets getInputSpecification() ... And that will overwrite my settings. I
> can fix this with setting 'preferFormInputFilter' on true. But I didn't have
> to do that in 2.2.2 so ...
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]