3
votes

How to generate 'a href="javascript:void(0)"' like link in CakePHP?

I make an application, the content will insert into the editor textarea when user click a list of image. I add a class to these images and write some code in the javascript file. Everything is going well.

But the link of the image is a URL address, but not 'href="javascript:void(0)' like URL. Anyone could tell me how to make it in CakePHP?

Thanks in advance!

2

2 Answers

6
votes
<?php 
   echo $this->Html->link(
        '/path/to/image/',
        'javascript:void(0)'
    );
?>

You can either set a path to the image or use the Html helper to generate the image tag code. The second parameter will set the href.

0
votes

Don't believe there is any dynamic way, however when you are creating your form element you can set it in the options array 'href' => 'javascript:void(0)'