CakePHP - 在 CakePHP 表单助手 link 中添加 HTML 内容的最佳方法?

CakePHP - Best approach to add HTML content inside CakePHP form helper link?

我正在尝试在 CakePHP 表单助手 link 生成器代码中添加一个图标。我在 Whosebug 上尝试了几个可用的选项。但似乎没有任何效果。

这是我当前的代码 - 我尝试了这个方法 Link

<?= $this->Html->link(('View'), ['action' => 'view', $group->id] , array('class' => 'dropdown-item' , 'between' => '<i class="la la-eye"></i>' , 'after' => '')) ?>

此方法在锚标记内创建属性。这不是我想要实现的目标。

我正在努力实现这一目标。

<a href="groups/view/1" class="dropdown-item"><i class="la la-pencil"></i> Edit</a>

我正在使用 CakePHP 3.7.4

阅读https://book.cakephp.org/3.0/en/views/helpers/html.html#creating-links

echo $this->Html->link(
    $this->Html->image("recipes/6.jpg", ["alt" => "Brownies"]),
    "recipes/view/6",
    ['escape' => false]
);

Will output:

<a href="/recipes/view/6" title="hi &quot;howdy&quot;">
    <img src="/img/recipes/6.jpg" alt="Brownies" />
</a>

你的情况:

echo $this->Html->link(
    "<i class="la la-pencil"></i> Edit",
    "recipes/view/6",
    ['escape' => false]
);