Array Filtering & Validation

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

Array Filtering & Validation

SiCo
Hi, I'm just playing with Zend InputFilter and am wondering whether it can filter arrays (i.e. filter each element of the passed array as an int)? My experiments so far don't bode well so I imagine it hasn't made it in. I thought the old filter_input did it?

i.e. array(0 => '1', 1 => '2', 2 => '3'); etc.

Hopefully I'm just missing a flag or doing it wrong!

How does a form handle validation of multi checkboxes, is that handled in the form or InputFilter?

Thanks for your help
Simon
Reply | Threaded
Open this post in threaded view
|

Re: Array Filtering & Validation

settermjd
I don't think there's a default filter class that handles that. Not 100% positive though.


Best,

Matthew Setter
Malt Blue Ltd
http://www.maltblue.com | [hidden email] | @maltblue
Connect with me on LinkedIn :: in/MatthewSetter

Am 6 Aug 2013 um 20:12 schrieb SiCo <[hidden email]>:

> Hi, I'm just playing with Zend InputFilter and am wondering whether it can
> filter arrays (i.e. filter each element of the passed array as an int)? My
> experiments so far don't bode well so I imagine it hasn't made it in. I
> thought the old filter_input did it?
>
> i.e. array(0 => '1', 1 => '2', 2 => '3'); etc.
>
> Hopefully I'm just missing a flag or doing it wrong!
>
> How does a form handle validation of multi checkboxes, is that handled in
> the form or InputFilter?
>
> Thanks for your help
> Simon
>
>
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/Array-Filtering-Validation-tp4660680.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>

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


Reply | Threaded
Open this post in threaded view
|

Re: Array Filtering & Validation

weierophinney
Administrator
In reply to this post by SiCo
On Tue, Aug 6, 2013 at 1:12 PM, SiCo <[hidden email]> wrote:

> Hi, I'm just playing with Zend InputFilter and am wondering whether it can
> filter arrays (i.e. filter each element of the passed array as an int)? My
> experiments so far don't bode well so I imagine it hasn't made it in. I
> thought the old filter_input did it?
>
> i.e. array(0 => '1', 1 => '2', 2 => '3'); etc.
>
> Hopefully I'm just missing a flag or doing it wrong!
>
> How does a form handle validation of multi checkboxes, is that handled in
> the form or InputFilter?

Filtering !== validation...

For multi checkboxes, radios, and multi-selects, we have an "Explode"
validator, that is used to validate each element of an array against
another validator chain. However, we do not pre-filter the values _in_
the array. The reason is that with the above form types, if the value
is not valid, somebody is most likely tampering with the input values
before submitting them.

Currently, if you want to filter all values of a submitted array,
you'll need to write a pre-processor of some sort to do that.

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

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