Using Foundation Icons in View Actions

I am using 3.8 and have included the foundation font icon file into the css, these load ok and are available in the views, however the View and Edit functions work as expected using the following:

<?= $this->Html->link(__(''), ['action' => 'view', $category->id],['class' => 'fi-zoom-in size-18', 'escape' => false]); ?>

Unfortunately trying to use something similar in the delete line results in the icon being shown which will immediately delete the row in question, the Confirm question seems to get bypassed?
I have tried every variation of this:

<?= $this->Form->postLink(__(''), ['action' => 'delete', $category->id], ['class' => 'fi-trash size-18', 'escape' => false],['confirm' => __('Are you sure you want to delete # {0}?', $category->id)]) ?>

I have tried every variation of this that I can think of to no avail.

I have found using the following code it wil work:
<?= $this->Form->postLink(
$this->Html->image(
“fi-trash.svg”,
[‘class’ => ‘SvgImage’],
[“alt” => __(‘Delete’)]
),
[‘action’ => ‘delete’, $category->id],
[‘escape’ => false, ‘confirm’ => __(‘Are you sure you want to delete this category?’, $category->id)]
)?>

but it would be nice to use a font icon instead? The SvgImage class merely sets the svg img to 10%

class, escape and confirm are all things that need to go in the $options array together. You’ve got the confirm moved into a separate array for some reason.

Thanks Zuluru worked like a charm, that must have been the only combination I failed to try, i’ll pay more attention to the square brackets in future :smile:

After Zuluru’s advice I also found this alternative:

<?= $this->Html->link('', ['controller' => 'categories', 'action' => 'view', $category->id ], ['escape' => false]); ?>

which seems to be clearer to read :slight_smile:

Please make sure that you understand the difference between link and postLink. They are different things, for different purposes. Both take parameters the same way.

Thanks Zuluru

I think I have it, the link does just that creates a link to some action whereas the postLink creates a form via javascript? I was struggling to get the system to just display the font icon :slight_smile:

Thanks again.