2010-07-05 146 views

回答

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> 

我也想告诉你用$this->Form->input('Model.field', 'options' => array(array('type' => 'button')));实验 - 尤其是之前,之间,之后,和类选项。您可以使用助手创建具有很大灵活性的<input type="button" />元素。

32

您可以使用表单助手的submit()button()方法而不是end()方法。例如:

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

不要忘记关闭窗体。您可以通过调用end()方法而无需任何参数。

echo $this->Form->end(); 
2

这是不够的:

echo $this->Form->submit("Custom message"); 

此外,作为@Mike建议与

echo $this->Form->end(); 
0

关闭窗体或者你可以结合两种:

echo $this->Form->end("Custom Message"); 
3

您可以创建costum提交通过此代码

echo $this->Form->submit(
    'Submit', 
    array('div' => false,'class' => 'urclass', 'title' => 'Title') 
); 
+0

感谢您分享。为你+1 – Pratik 2015-04-16 17:34:23

0

我在使用内嵌样式用于指定尺寸和改变位置我下的应用程序/ Web根目录/ IMG创建使用图像的自定义按钮,中心

$options=array('type'=>'Make secure payment', 'type'=>'image', 'style'=>'width:200px; height:80px; display:block; margin-left:auto; margin-right:auto;'); 
echo $this->Form->submit('/img/axiaepaysecurebuttongray_med.png', $options); 
echo $this->Form->end(); 
0

对于CakePHP的2.x中,你可以使用

$options = array(
    'label' => 'Update', 
    'div' => array(
     'class' => 'glass-pill', 
    ) 
); 
echo $this->Form->end($options);