Monday 23 May 2011

Disabling CakePHP Auto Escape In Helpers

As we know, CakePHP will automatically escape special characters to sanitize the data.
Sometimes we do not want to escape the special characters, for example "Textarea" inputs, or some inline javascript (eg: onclick= "return function ('xxxx')" when we are using form/html helpers.
For these reasons, we can declared
'escape'=>false

in the $options (or $attribute ??) array.
As a result, the special characters in html code will be preserved.

Example:
echo $html->tableCells    (array    (array    ($form->checkbox('Checkbox1', array    ('escape'=>false,'onlick'=>'return checkbox(\'CheckboxCheckbox1\')')) ..... 


Reference:
Look for the first reply of the article.

No comments: