【发布时间】:2012-01-09 19:46:05
【问题描述】:
是否可以使用 CakePHP 中的 html 帮助程序创建一个带有弹出警报 [$confirmMessage] 的链接的图像?
这是我当前的文本链接:
$this->Html->link('Clear list', array('controller' => 'items', 'action' => 'clearlist', $model['Model']['id']), array(), 'Clear list?')
图像助手如何使用链接创建图像:
echo $this->Html->image("recipes/6.jpg", array( "alt" => "Brownies", 'url' => array('controller' => 'recipes', 'action' => 'view', 6)));
但是,这仅允许 htmlattributes 数组作为链接的参数。
$confirmMessage 警报不是 html 属性吗?
这是我试过的代码:
echo $this->Html->link($this->Html->image("clearall.png", array("alt" => "Clear list")), array('controller' => 'items', 'action' => 'clearlist', $model['Model']['id']), array(), 'Clear list?');
然而,这段代码为我的 img 打印了正确的 html 作为文本:
<img src="/img/clearall.png" alt="Clear list" />
在这种情况下我必须放弃 htmlhelper 吗?
【问题讨论】:
标签: cakephp hyperlink html-helper image