I want to output an image with a hyperlink wrapped around it instead of just a text hyperlink using cakePHP's formHelper::postLink function.
Does anyone know how to do this? I tried multiple things but couldn't get it working.
<?php echo $this->Form->postLink(
'Delete',
array('action' => 'delete', $country['Country']['id']),
array('confirm' => __('Are you sure you want to delete ').$country['Country']['name'].'?')
)?>
So instead of 'Delete' I want to display an image.
Here's what works for me.
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
Try this :
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?'))
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With