html 元素内的表单元素在 cakephp 中不起作用

Form element inside html element not working in cakephp

我已经阅读了文档并尝试了所有可能的解决方案,但没有收获。

这是我的html代码

<?php echo $this->Html->link(
$this->Form->button("Continue", ["type" => "button", "class"=>"btn btn-dark btn-theme-colored btn-flat mr-5"]),
array(
'controller' => 'my_controller',
'action' => 'my_action'
));?>

我想在 <a> 标签内有一个按钮,但它在 '' " 标签中输出按钮。

这就是我想要的

<i>
   <button></button>
</i>

所有特殊字符都将转换为 html 实体,除非您使用转义选项禁用此行为。下面的代码应该输出你想要的:

<?php echo $this->Html->link(
$this->Form->button("Continue", ["type" => "button", "class"=>"btn btn-dark 
btn-theme-colored btn-flat mr-5"]),
array(
    'controller' => 'my_controller',
    'action' => 'my_action'
),
array(
    'escape' => false
));?>

更多关于 HTML 助手的信息可以在这里找到:https://book.cakephp.org/3.0/en/views/helpers/html.html#creating-links