Skip to content Skip to sidebar Skip to footer

Image Link With $confirmmessage Alert In Cakephp Htmlhelper - Possible?

Is it possible to create an image with a link that also has a pop up alert [$confirmMessage] using the html helper in CakePHP? This is my current text link: $this->Html->link

Solution 1:

CakePHP does do this with the Html helper and you were really close!

<?phpecho$this->Html->link($this->Html->image('clearall.png', array(
                                                    'alt' => 'Clear list')
                                               ), array(
                                                    'controller' => 'items',
                                                    'action' => 'clearlist',
                                                    $model['Model']['id']
                                               ), array(
                                                    'escape' => false,
                                                    'confirm' => 'Clear list?'
                                               )); ?>

You could also have done it without the helper like so:

<ahref="/items/clearlist/<?phpecho$model['Model']['id']; ?>"onclick="return confirm(&#039;Clear list?&#039;);"><imgsrc="/img/clearall.png"alt="Clear list" /></a>

Thanks to ADmad and rtconner for showing me this in IRC.

Post a Comment for "Image Link With $confirmmessage Alert In Cakephp Htmlhelper - Possible?"