views:

706

answers:

2

How do I apply stripslashes() to all form elements prior to output with Zend_Form?

I have tried:

//the filter
class lib_filters_Stripslashes implements Zend_Filter_Interface{
    public function filter($value){
     return stripslashes($value);
    }
}
...
...
...

//In the form
$form->setElementFilters(array(new lib_filters_Stripslashes));
+1  A: 

I trim all form elements with

array_map('trim', $_POST)
Galen
What does trimming have to do with stripping slashes?
Peter Smit
The same method, exactly, could be applied to stripslashes
Itay Moav
+2  A: 

If you find that you need to stripslashes on all fields, most likely, your web host is configured to run with the deprecated magic-quotes setting turned on. If you are able, I would recommend that you turn it off instead.

troelskn
The best suggestion yet! I also wouldn't fix some obscure issue, but instead get to the root of it.
Till