首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cakePHP formHelper postLink图像

cakePHP formHelper postLink图像
EN

Stack Overflow用户
提问于 2011-11-12 23:38:23
回答 6查看 12K关注 0票数 4

我想使用cakePHP的formHelper::postLink函数输出一个包含超链接的图像,而不仅仅是一个文本超链接。

有人知道怎么做吗?我尝试了很多方法,但都不能让它工作。

代码语言:javascript
复制
<?php echo $this->Form->postLink(
    'Delete',
    array('action' => 'delete', $country['Country']['id']),
    array('confirm' => __('Are you sure you want to delete ').$country['Country']['name'].'?')
)?>

所以我想要显示一张图片,而不是“删除”。

EN

回答 6

Stack Overflow用户

发布于 2011-12-14 21:00:40

以下是对我有效的方法。

代码语言:javascript
复制
echo $this->Form->postLink(
  $this->Html->image('icn_trash.png', array('alt' => __('Effacer'))), //le image
  array('action' => 'delete', $artist['Artist']['id']), //le url
  array('escape' => false), //le escape
  __('Êtes-vous sûr de vouloir effacer artiste #%s?', $artist['Artist']['id']) //le confirm
); //le voila
票数 9
EN

Stack Overflow用户

发布于 2011-11-18 17:41:34

试试这个:

代码语言:javascript
复制
echo $this->Form->postLink(
    $this->Html->image('delete.png',
       array("alt" => __('Delete'), "title" => __('Delete'))), 
    array('action' => 'delete', $items['Item']['id']), 
    array('escape' => false, 'confirm' => __('Are you sure?')) 
);
票数 4
EN

Stack Overflow用户

发布于 2011-11-13 00:16:09

如果我没理解错你的问题,我认为你不想用$this->Form->postLink

我想这个页面就是你想要的:http://book.cakephp.org/view/1441/image

这将使用$this->Html->image创建图像,然后您可以传递一个URL作为参数之一,以指定周围的锚点链接。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8105450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档