RE: [fw-general] Zend_Filter_Input 'missing' question

2007-07-02 Thread Bill Karwin
This is intended behavior.
Missing fields are not reported as missing unless you specify
'presence'=>'required' in the rule.  
If a field is not required to be present, nobody misses it when it's not
there.  :-)

Regards,
Bill Karwin 

> -Original Message-
> From: Lepidosteus [mailto:[EMAIL PROTECTED] 
> Sent: Monday, July 02, 2007 6:22 PM
> To: fw-general@lists.zend.com
> Subject: [fw-general] Zend_Filter_Input 'missing' question
> 
> Hello,
> 
> I'm using a Zend_Filter_Input to get my data from the user.
> 
> I'm not correctly understanding its behavior with missing 
> fields (zf 1.0.0),
> 
> here is some code:
> 
> $filters = array(
> 'description'   => array('StringTrim', 'HtmlEntities'),
> 'upload' => 'StringTrim',
> 'whateverwrongvalue' => 'StringTrim',
> 'review' => 'Int'
> );
> $validators = array(
> 'description'   => 'NotEmpty',
> 'upload' => 'NotEmpty',
> 'whateverwrongvalue' => 'NotEmpty',
> 'review' => array(array('Between', 0, 1))
> );
> $input = new Zend_Filter_Input($filters, $validators, $_POST);
> if ($input->hasInvalid() || $input->hasMissing()) {
> format_error_message($input->getInvalid(),
> $input->getMissing(), $input->getUnknown());
> }
> 
> I then create a form which contains all these fields except 
> 'whateverwrongvalue' (aka, it should be reported as a missing 
> field if I get it).
> 
> Problem is, it isn't. If some field (say, 'description') is 
> invalid, the 'if' fails and I get a valid error message etc ...
> 
> But I never get anything about a missing field
> 
> (unknown fields are reported the way they should be)
> 
> Is it me misunderstanding the behavior or did I do something wrong ?
> 
> --
> Vianney Devreese - Lepidosteus
> http://lepidosteus.com
> 


[fw-general] Zend_Filter_Input 'missing' question

2007-07-02 Thread Lepidosteus

Hello,

I'm using a Zend_Filter_Input to get my data from the user.

I'm not correctly understanding its behavior with missing fields (zf 1.0.0),

here is some code:

$filters = array(
   'description'   => array('StringTrim', 'HtmlEntities'),
   'upload' => 'StringTrim',
   'whateverwrongvalue' => 'StringTrim',
   'review' => 'Int'
   );
   $validators = array(
   'description'   => 'NotEmpty',
   'upload' => 'NotEmpty',
   'whateverwrongvalue' => 'NotEmpty',
   'review' => array(array('Between', 0, 1))
   );
   $input = new Zend_Filter_Input($filters, $validators, $_POST);
   if ($input->hasInvalid() || $input->hasMissing()) {
   format_error_message($input->getInvalid(),
$input->getMissing(), $input->getUnknown());
   }

I then create a form which contains all these fields except
'whateverwrongvalue' (aka, it should be reported as a missing field if
I get it).

Problem is, it isn't. If some field (say, 'description') is invalid,
the 'if' fails and I get a valid error message etc ...

But I never get anything about a missing field

(unknown fields are reported the way they should be)

Is it me misunderstanding the behavior or did I do something wrong ?

--
Vianney Devreese - Lepidosteus
http://lepidosteus.com