CakePHP’s HtmlHelper::link() Escaping of Attribute Values Gotcha

Just updated pHing Classifieds to CakePHP 1.2.2.8120 and that breaks some JavaScript codes for deleting of messages. Turns out the escape attribute is now passed on to Helper::parseAttributes() so if you have an image link like me, you will have to remember to manually escape the attribute values.

<?= $appHtml->link(
   $appHtml->image('icons/bin.png'),
   '#',
   array(
      'escape' => false,
      'onclick' => h('if (confirm("True?")) alert ("Yes"); return false;')
   )
) ?>

Not a big issue and it probably seem more consistent that the escape option is applied to both the link title and the HTML attributes. See ticket #6071 for why it was changed and what was changed.

Bookmark and Share
This entry was posted in Uncategorized and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
    blog comments powered by Disqus