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!

<?php echo $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:

<a href="/items/clearlist/<?php echo $model['Model']['id']; ?>"
   onclick="return confirm(&#039;Clear list?&#039;);">
    <img src="/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?"