CakePHP 将重置和提交按钮放在同一行

CakePHP Put Reset & Submit Button on the Same Line

我发现当我使用 $this->Form->submit 时,提交按钮被包裹在 div.form-group 中。

echo $this->Form->submit('submit', array(
            'div' => 'form-group',
            'class' => 'btn btn-primary'
));
echo $this->Form->button('Reset', array('type'=>'reset' ,'class' => 'btn btn-primary'));
echo $this->Form->end();

您可以将 div 设置为 false 以禁用两个按钮上的换行 div,然后只需手动回显 div:

echo '<div>';
echo $this->Form->submit('submit', array(
    'div' => false,
    'class' => 'btn btn-primary'
));
echo $this->Form->button('Reset', array(
    'type'=>'reset',
    'class' => 'btn btn-primary'
    'div' => false
));
echo '</div>';