自定义提交按钮

use*_*003 15 forms cakephp submit button

如何创建提交按钮,并在其上定义自定义标题以及自定义类样式?

Mik*_*ike 33

您可以使用Form帮助程序中的任一个submit()button()方法而不是end()方法.例如:

echo $this->Form->submit(
    'Send', 
    array('class' => 'custom-class', 'title' => 'Custom Title')
);
Run Code Online (Sandbox Code Playgroud)

别忘了关闭表格.你可以通过调用end()没有任何参数的方法来实现.

echo $this->Form->end();
Run Code Online (Sandbox Code Playgroud)


Abb*_*ant 10

还记得,你可以随时做旧学校

我更喜欢$this->Form->end( );不带参数使用并构建我自己的提交按钮和标记.这很简单

<div class="buttons clearfix">
    <button type="submit" class="positive">
        <span class="icon-wrapper"><img src="path/to/tickmark.png" alt="" title="" /></span>
        Save Item
    </button>
</div>
Run Code Online (Sandbox Code Playgroud)

我还会告诉你试验$this->Form->input('Model.field', 'options' => array( array('type' => 'button')));- 尤其是之前,之间,之后和类选项.您可以使用帮助程序创建<input type="button" />具有良好灵活性的元素.