>From http://framework.zend.com/manual/en/zend.filter.input.html:

"All fields that are neither invalid, missing, nor unknown are
considered valid. You can get values for valid fields using a magic
accessor. There are also non-magic accessor methods getEscaped() and
getUnescaped()."

I believe that the behavior you're seeing is expected, as
Zend_Filter_Input does not make available invalid data by design.

Best regards,
Darby

ArticSun wrote:
> I'm not sure if I got what it takes to add critical notes to the Zend
> Framework ;).
> 
> About the fields problem... In the .phtml I write data from an array to the
> value attribute of input fields.
> It seems that if a certain key is not available in the array it writes the
> '<br />'.
> 
> So I can check if the key exists, but well.. that's a lot of extra code :).
> 
> I just put the data array through a simple filter:
> 
> // Zend_Filter_Input options.
> $aOptions = array('allowEmpty' => true);
> 
> // Zend_Filter_Input filters.
> $aFilters = array();
> 
> // Zend_Filter_Input validators.
> $aValidators = array(
>    'id' => array(
>       'Digits'
>    ),
>    'relation_id' => array(
>       new Zend_Validate_Regex('/^[0-9]{1,}$/'),
>       'presence' => 'required',
>       'allowEmpty' => false,
>       'messages' => 'Selecteer een relatie.'
>    )
> ); // Etc.
> 
> // Apply the filter to the post data.
> $oFilter = new Zend_Filter_Input($aFilters, $aValidators,
> $this->_request->getPost(), $aOptions);
> 
> // Save the data in the class var (escaped / html removed).
> $this->_aCheckedData['contact'] = $oFilter->getEscaped();
> return;
> 
> When a field is not filled in correctly conforming the filter, it seems the
> key in the array $this->_aChekcedData['contact'] is removed.
> 
> Thanks!
> 
> 
> 
> Darby Felton wrote:
>> Hi,
>>
>> Have you tried using Zend_Validate_EmailAddress? If for some reason it
>> is unsatisfactory for your use case, you can help us to improve it by
>> discussing the shortcomings you encounter here, and filing issues in the
>> JIRA issue tracker:
>>
>> http://framework.zend.com/issues/secure/CreateIssue!default.jspa
>>
>> If you do not already have authorization to create issues, first create
>> an account, and then simply send an e-mail to [EMAIL PROTECTED] requesting
>> permission to post issues and comments.
>>
>> As for the second question, I think we'll need more information to be
>> able to help you:
>>
>> How to Report Bugs Effectively
>> http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
>>
>> Best regards,
>> Darby
>>
>> ArticSun wrote:
>>> Hi all!
>>>
>>>    I got two questions about validating form data. The first one might be
>>> the simplest. I've got a regular expression which checks if an e-mail
>>> address is correct:
>>>
>>> new
>>> Zend_Validate_Regex("/^$|^[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*@(([a-z]([-a-z0-9]*[a-z0-9]+)?){1,63}\.)+([a-z]([-a-z0-9]*[a-z0-9]+)?){2,63}$/")
>>>
>>> I've added the / at the beginning and end because other expressions
>>> wouldn't
>>> work without it. This expression works when I use it in "ereg" for
>>> example.
>>> I now get the error: "Internal error matching pattern {the pattern}".
>>> Does
>>> anyone know what I'm doing wrong, or what would be a good expression (but
>>> I
>>> don't want to make this a script request!).
>>>
>>> The second question is about fields that get a <br /> when the value was
>>> not
>>> right regarding the validator. I do something like:
>>>
>>> // Apply the filter to the post data.
>>> $oFilter = new Zend_Filter_Input($aFilters, $aValidators,
>>> $this->_request->getPost(), $aOptions);
>>>
>>> // Save the data in the class var (escaped / html removed).
>>> $this->_aCheckedData['relation'] = $oFilter->getEscaped();
>>>
>>> When there are errors I show the form again. I try to print the data
>>> again
>>> (the data I put in _aCheckedData['relation'] here), and now the field
>>> that
>>> was not correct, contains "<br />", in stead of the value the user filled
>>> in.
>>>
>>> What could I be doing wrong here? If you need more information, please
>>> ask.
>>>
>>> Thanks!
>>
> 

Reply via email to