Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:47:08+00:00 2026-05-28T02:47:08+00:00

Is it possible to create an image with a link that also has a

  • 0

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('Clear list', array('controller' => 'items', 'action' => 'clearlist', $model['Model']['id']), array(), 'Clear list?')

This how the image helper creates images with links:

echo $this->Html->image("recipes/6.jpg", array( "alt" => "Brownies", 'url' => array('controller' => 'recipes', 'action' => 'view', 6)));

However this allows only an htmlattributes array as the arguements for the link.

The $confirmMessage alert is not an html attribute is it?

This is the code I tried:

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

However this code printed the correct html for my img as text:

<img src="/img/clearall.png" alt="Clear list" />

Do I have to give up on htmlhelper in this case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:47:09+00:00Added an answer on May 28, 2026 at 2:47 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create a cursor from an image and have it be
Is it possible to create a trigger that will not be in a transaction?
I'm trying to create a thumbnail image on the client side using javascript and
Is it possible to create a bitmap image from a view or the screen
I'm trying to create an image rotator class that cycles through an arbitrary number
Is it possible to redirect an image to a dynamically generated image(using PHP)? I
How would I create a text link to the first image attachment page in
Is it possible to create a Floated Image with text flowing around it in
This is a variation on a question that has been asked here several times.
When I create a link to an image I'd like for a download dialog

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.