How do I prevent $html-link() from removing the single quotes when adding an 'onmouseover' event in CakePHP?
-
03-07-2019 - |
Question
Trying to use an onmouseover event
echo $html->link("Dashboard",
"/dashboard/index",
array("onmouseover" => "Tip('Test');") );
becomes
<a href="/dashboard/index" onmouseover="Tip('Test');">Dashboard</a>
How do I prevent the link function from removing the single quotes?
Solution
Using Cake 1.2, this should definitely work:
echo $html->link('Dashboard', '/dashboard/index',
array("onmouseover" => "Tip('Test');"), null, false);
The last parameter is the escape option. It defaults to true.
OTHER TIPS
This should work:
echo $html->link("Dashboard",
"/dashboard/index",
array("onmouseover" => "Tip('Test');"),
array('escape' => false));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow