【发布时间】:2011-03-12 01:26:09
【问题描述】:
如何创建提交按钮,并在其上定义自定义标题以及自定义类样式?
【问题讨论】:
标签: cakephp forms button submit
如何创建提交按钮,并在其上定义自定义标题以及自定义类样式?
【问题讨论】:
标签: cakephp forms button submit
另外请记住,你总是可以做到的老派
我更喜欢使用不带参数的$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" /> 元素。
【讨论】:
这就够了:
echo $this->Form->submit("Custom message");
@Mike 也建议用
关闭表单echo $this->Form->end();
【讨论】:
或者您可以将两者结合:
echo $this->Form->end("Custom Message");
【讨论】:
您可以通过此代码创建服装提交
echo $this->Form->submit(
'Submit',
array('div' => false,'class' => 'urclass', 'title' => 'Title')
);
【讨论】:
我使用我在 app/webroot/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();
【讨论】:
对于 CakePHP 2.x,你可以使用
$options = array(
'label' => 'Update',
'div' => array(
'class' => 'glass-pill',
)
);
echo $this->Form->end($options);
【讨论】: