使用CakePHP'创建带有链接的按钮;s HTML/表单帮助程序

使用CakePHP'创建带有链接的按钮;s HTML/表单帮助程序,cakephp,Cakephp,我想使用CakePHP帮助程序将链接转换为按钮 使用$this->Html->link()我可以使用数组()包含'action'=>'view'$用户['user']['id'],但我不确定在使用$this->Form->button()时如何包含此内容 使用$this->Html->link(): 我的解决方案 我的解决方案不允许我添加“操作”=>“视图”$用户['user']['id'] 使用$this->Form->button(): 使用标记: <input type="butto

我想使用CakePHP帮助程序将链接转换为按钮

使用
$this->Html->link()
我可以使用数组()包含
'action'=>'view'$用户['user']['id']
,但我不确定在使用
$this->Form->button()
时如何包含此内容

使用
$this->Html->link()

我的解决方案 我的解决方案不允许我添加
“操作”=>“视图”$用户['user']['id']

使用
$this->Form->button()

使用
标记:

<input type="button" class="btn btn-primary" value="Click me" 
    onclick="location.href='http://www.domain.com';">
<button class="btn btn-success" onclick="location.href='http://www.domain.com';">
    Click me
</button>

使用
标记:

<input type="button" class="btn btn-primary" value="Click me" 
    onclick="location.href='http://www.domain.com';">
<button class="btn btn-success" onclick="location.href='http://www.domain.com';">
    Click me
</button>

点击我

如果您使用的是cakephp 2.X及以上版本,请将这行代码用于“链接入”按钮:

<button onclick="window.location.href='<?php echo Router::url(array('controller'=>'Users', 'action'=>'admin_index'))?>'">;Go Back</button>;

HTML5按钮具有用于此用途的formaction属性。当然,这只适用于现代浏览器

$this->Form->button(
    'Click me', 
    array(
        'formaction' => Router::url(
            array('controller' => 'users','action' => 'view' . $user['User']['id'])
         )
    )
);

用onclick将链接更改为按钮?听起来你真的想把你的链接设计成一个按钮——这是你应该单独用css来做的。太棒了!非常感谢你,@arilia