2015-10-12 65 views
0

這就是我現在所擁有的。如何添加圖像來形成蛋糕php中的postlink?

$this->Form->postLink(
    __('Delete Client'), 
    ['action' => 'delete', $client->id], 
    ['confirm' => __('Are you sure you want to delete # {0}?', $client->id)] 
) 

如何使用選項數組將圖像添加到此鏈接?

+0

[CakePHP可能重複 - 使用$ this-> Html->鏈接$ this-> Html-> image ....生成ascii而不是實際的HTML](http://stackoverflow.com/questions/15007396/cakephp-using-this-html-link-with-this-html-image-generating-ascii-in) – AD7six

回答

1
$this->Form->postLink(
    $this->Html->image(
     "action-delete.svg", 
     ["alt" => "Delete Client", 'class' => 'action-link'] 
    ), 
    ['controller' => 'clients', 'action' => 'delete', $client->id], 
    ['escape' => false, 'confirm' => __('Are you sure you want to delete # {0}?', $client->id)] 
) 
+0

你應該解釋你的答案。特別是如前所述,對讀者來說,你不一定會明白你已經改變了什麼。你的實際源代碼是全部寫在一行嗎?你怎麼能讀到:P – AD7six

0

請嘗試我的作品完美!

echo $this->Form->postLink($this->Html->image('1.png'), ['action' => 'delete',$client->id],['escape' => false, 'title' => 'Delete', 'confirm' => __('Are you sure you want to delete # {0}?'),$client->id)]);?> 

謝謝!