Steve Rayner-2 wrote
>
> Can anyone point me to (or give me) an example of an input filter for
> an integer? My requirements are that we ensure the input is an
> integer, it is required and it must fall between and min and max
> values (inclusive). I can probably just about figure this out, but
> should i be doing things like strip tags? I'm guessing not because if
> we are ensuring it is a number the tags can't be present can they?
>
> I'm guessing something like this;
>
> $inputFilter->add($factory->createInput(array(
> 'name' => 'somevalue',
> 'required' => true,
> 'validators' => array(
> array(
> 'name' => 'Int',
> 'options' => array(
> 'min' => 1,
> 'max' => 50,
> ),
> ),
> ),
> )));
>
In your case you may want to give a go the code below:
Int filter is to ensure that any inserted string is casted into integer and
Between checks for what you require.
$inputFilter->add($factory->createInput(array(
'name' => 'somevalue',
'required' => true,
'filters' => array(
array('name' => 'Int'),
),
'validators' => array(
array(
'name' => 'Between',
'options' => array(
'min' => 1,
'max' => 50,
),
),
),
)));
-----
Cheers,
--
Luke Mierzwa
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF2-integer-inputfilter-tp4656882p4656885.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]