Quantcast

Zend_Form and getValidValues

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Zend_Form and getValidValues

Razorblade

Hello Everyone,
I am a bit confused with the "getValidValues" method of Zend_Form.
I am using ZF 1.11.10.

I'll explain my problem:

I'm trying to get all the valid values of the $data array.

$isValid = $form->isValid( $data );

            if( $isValid ) {
                $validValues = $form->getValidValues();
                Zend_Debug::dump( $validValues, 'validValues' ); exit;
            } else {
                 Zend_Debug::dump( $form->getErrors() ); exit;
            }

If $data contains keys that are not form elements, $validValues will contains them.
Is that the correct behaviour of this method?

The result I would is an array of data that is valid and is present as a form element, discarding what is not present,
is there any way to accomplish this using Zend Form methods or maybe am I mistaking something?

Thanks

Sergio


     
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Form and getValidValues

Razorblade
This post has NOT been accepted by the mailing list yet.
Yes, my mistake,
issue found :)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Form and getValidValues

Konr Ness
In reply to this post by Razorblade
I don't think getValidValues() is the right method for your needs.

When you call isValid($data) on a form, the form elements are
populated and validated. getValidValues() is expecting a parameter of
$data as well, but in looking through the code it looks like it passes
on values that don't exist in the form.

So, instead you should just call getValues() on the form. This will
return only the values for form elements that exist in the form.

Konr

On Thu, Sep 15, 2011 at 4:50 PM, Sergio Rinaudo
<[hidden email]> wrote:

>
> Hello Everyone,
> I am a bit confused with the "getValidValues" method of Zend_Form.
> I am using ZF 1.11.10.
>
> I'll explain my problem:
>
> I'm trying to get all the valid values of the $data array.
>
> $isValid = $form->isValid( $data );
>
>            if( $isValid ) {
>                $validValues = $form->getValidValues();
>                Zend_Debug::dump( $validValues, 'validValues' ); exit;
>            } else {
>                 Zend_Debug::dump( $form->getErrors() ); exit;
>            }
>
> If $data contains keys that are not form elements, $validValues will contains them.
> Is that the correct behaviour of this method?
>
> The result I would is an array of data that is valid and is present as a form element, discarding what is not present,
> is there any way to accomplish this using Zend Form methods or maybe am I mistaking something?
>
> Thanks
>
> Sergio
>
>
>

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend_Form and getValidValues

Razorblade
This post has NOT been accepted by the mailing list yet.
Hi Konr ,
yes, you're right, I was mistaking in another part of my code and also not to pass tha required argument,
I've found it a few minutes after I opened this post and replied to my own question, but I see the message "This post has NOT been accepted by the mailing list yet." so maybe you cannot see it.

However, thank you for your answer, is always good to have some good advice from a friend!

Regards
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Zend_Form and getValidValues

Razorblade
In reply to this post by Konr Ness

Hi Konr ,

yes, you're right, I was mistaking in another part of my code and also not to pass tha required argument,

I've found it a few minutes after I opened this post and replied to
my own question, but I see the message "This post has NOT been accepted
by the mailing list yet." so maybe you cannot see it.


However, thank you for your answer, is always good to have some good advice from a friend!


Regards


Sergio Rinaudo




> Date: Mon, 19 Sep 2011 14:11:14 -0500
> Subject: Re: [fw-general] Zend_Form and getValidValues
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
>
> I don't think getValidValues() is the right method for your needs.
>
> When you call isValid($data) on a form, the form elements are
> populated and validated. getValidValues() is expecting a parameter of
> $data as well, but in looking through the code it looks like it passes
> on values that don't exist in the form.
>
> So, instead you should just call getValues() on the form. This will
> return only the values for form elements that exist in the form.
>
> Konr
>
> On Thu, Sep 15, 2011 at 4:50 PM, Sergio Rinaudo
> <[hidden email]> wrote:
> >
> > Hello Everyone,
> > I am a bit confused with the "getValidValues" method of Zend_Form.
> > I am using ZF 1.11.10.
> >
> > I'll explain my problem:
> >
> > I'm trying to get all the valid values of the $data array.
> >
> > $isValid = $form->isValid( $data );
> >
> >            if( $isValid ) {
> >                $validValues = $form->getValidValues();
> >                Zend_Debug::dump( $validValues, 'validValues' ); exit;
> >            } else {
> >                 Zend_Debug::dump( $form->getErrors() ); exit;
> >            }
> >
> > If $data contains keys that are not form elements, $validValues will contains them.
> > Is that the correct behaviour of this method?
> >
> > The result I would is an array of data that is valid and is present as a form element, discarding what is not present,
> > is there any way to accomplish this using Zend Form methods or maybe am I mistaking something?
> >
> > Thanks
> >
> > Sergio
> >
> >
> >
     
Loading...