How do I prevent $html-link() from removing the single quotes when adding an 'onmouseover' event in CakePHP?

StackOverflow https://stackoverflow.com/questions/815721

  •  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(&#039;Test&#039;);">Dashboard</a>

How do I prevent the link function from removing the single quotes?

Was it helpful?

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
scroll top