Is there any way to output all filtered data from the class Zend_Filter_Input?
4
-
How do you mean? The filtered data? Why? $data = $myFilter->filter($data); is not direct enough?markus– markus2009-07-23 10:12:40 +00:00Commented Jul 23, 2009 at 10:12
-
$_data: array Input data, before processing. Why would you need that value?smoove– smoove2009-07-23 11:03:34 +00:00Commented Jul 23, 2009 at 11:03
-
To tharkun: Yes, I need the filtered data but Zend_Filter_Input doesn't have a filter() functionAlan– Alan2009-07-24 01:45:30 +00:00Commented Jul 24, 2009 at 1:45
-
To smoove666: Sorry I have made a mistake. Actually I need the data after processing.Alan– Alan2009-07-24 01:47:07 +00:00Commented Jul 24, 2009 at 1:47
Add a comment
|
2 Answers
Zend_Filter_Input offers numerous methods for retrieving filtered and validated data.
First, you can retrieve an associative array of all fields:
$data = $input->getEscaped(); // Retrieve all data, escaped with Zend_Filter_HtmlEntities
$data = $input->getUnescaped(); // Retrieve all data, not escaped.
You can also get an associative array of certain segments of you data, the method names are very clear:
$invalidFields = $input->getInvalid(); // Fields that failed validation
$missingFields = $input->getMissing(); // Fields that were declared as 'required' using the 'presence' metacommand, but not in the input
$unknownFields = $input->getUnknown(); // Fields that were not declared in the validator rules, but were present in the input.
On top of all that, Zend_Filter_Input offers an object accessor, through an implementation of the __get magic method:
$oneField = $input->oneFieldName
Comments
In form you can get unfiltered values. Check the manual ;)
1 Comment
Alan
Sorry I have made a mistake. I need to get an array storing all filtered data.