Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

weierophinney
Administrator
On Fri, Aug 23, 2013 at 3:27 AM, Wim Kumpen <[hidden email]> 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            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
Reply | Threaded
Open this post in threaded view
|

Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

Ralf Eggert
Hi,

> 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?

I don't get this issue since I use the Input Filter itself to validate
the data without the form. But if the default behaviour changed within
the 2.2.* release path there should be an immediate 2.2.4 with the flag
set to true.

If this would have happened with the 2.3.0 I wouldn't care at all...

Thanks and best regards,

Ralf
Reply | Threaded
Open this post in threaded view
|

Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

Gabriel403
This post has NOT been accepted by the mailing list yet.
In reply to this post by weierophinney
Personally I feel that if people were relying on a bug (without knowing it was a bug) then the fix is a bc, yay for fixing bugs, boo for the bc break. Sure it's only a minor change to fix it for themselves, but I still think we should fix it so the original behaviour happens soon

Gabriel


On 23 August 2013 19:04, weierophinney [via Zend Framework Community] <[hidden email]> wrote:
On Fri, Aug 23, 2013 at 3:27 AM, Wim Kumpen <[hidden email]> 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            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc



To start a new topic under ZF Contributor, email [hidden email]
To unsubscribe from ZF Contributor, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

Michael Gooden
In reply to this post by weierophinney
Hi Matthew,

Even though the 2.2.3 release fixed the previously undiscovered bug, it has as you noted broken the behaviour that has been standard so far.

I recommend towards setting the flag to true by default, and either an immediate 2.2.4 release, or a notification of some type as to the usage of the setPreferFormInputFilter method. I strongly recommend an immediate release of 2.2.4, as I upgraded to 2.2.3 via composer, which means I did not immediately see the changelog, just a broken application.

Regards,

Michael Gooden


On 23 August 2013 19:52, Matthew Weier O'Phinney <[hidden email]> wrote:
On Fri, Aug 23, 2013 at 3:27 AM, Wim Kumpen <[hidden email]> 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            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Reply | Threaded
Open this post in threaded view
|

AW: [zf-contributors] Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

Marc Tempelmeier
In reply to this post by weierophinney
Hi,

+1 for default in an immediate 2.2.4 release, because it breaks my
+forms. :)

Greetings

Marc

> -----Ursprüngliche Nachricht-----
> Von: Matthew Weier O'Phinney [mailto:[hidden email]]
> Gesendet: Freitag, 23. August 2013 19:52
> An: lists lists
> Cc: lists lists
> Betreff: [zf-contributors] Re: [fw-general] zend framework 2.2.3 : non
> required form fields not working anymore?
>
> On Fri, Aug 23, 2013 at 3:27 AM, Wim Kumpen
> <[hidden email]> 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            | [hidden email]
> Zend Framework          | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc