Zend_Form, setAttrib('escape',false) not working, help
I am using Zend_Form and I would like one of my elements to not escape. I have the following code, I think it should not escape but it does without fail:
In form class:
$btc_name = $this->createElement('text','btc_name');
$btc_name->setLabel('Company Name')
->setRequired(true)
->setAttrib('size',45)
->setAttrib('escape',false)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
Output html:
<dt id="btc_name-label"><label for="btc_name" class="required">Company Name</label></dt> <dd id="btc_name-element"><input type="text" name="btc_name" id="btc_name" value="Joe\'s Tire Warehouse" s开发者_Go百科ize="45" /></dd>
You can see the form in action with a print_r of the $formData and getValue of the field here: Link Removed
Any help would be greatly appreciated.
Thanks, Joe Chin
Assuming it's the backslash you're referring to, it's likely to be PHP that's adding this, not Zend Framework. Check your php.ini file and look for a setting called magic_quotes_gpc - you want this to be off (unless you have other things relying on it). If you can't alter your php.ini file but are using mod_php, you can override this in a .htaccess file:
php_value magic_quotes_gpc off
See http://php.net/manual/en/security.magicquotes.php for some background, and why it is bad.
精彩评论