[英]Custom Submit button
如何创建提交按钮,并在其上定义自定义标题以及自定义类样式?
You could use either submit()
or button()
methods of the Form helper instead of the end()
method. 您可以使用Form帮助程序的
submit()
或button()
方法而不是end()
方法。 For example: 例如:
echo $this->Form->submit(
'Send',
array('class' => 'custom-class', 'title' => 'Custom Title')
);
Don't forget to close the form. 别忘了关闭表格。 You can do it by calling the
end()
method without any arguments. 你可以通过调用没有任何参数的
end()
方法来实现。
echo $this->Form->end();
Also remember, you can always do it old school 还记得,你可以随时做旧学校
I prefer to use $this->Form->end( );
我更喜欢使用
$this->Form->end( );
without arguments and build my own submit buttons and markup. 没有参数并构建我自己的提交按钮和标记。 It's easy
这很简单
<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>
I would also tell you to experiment with the $this->Form->input('Model.field', 'options' => array( array('type' => 'button')));
我还会告诉你
$this->Form->input('Model.field', 'options' => array( array('type' => 'button')));
- particularly the before, between, after, and class options. - 特别是之前,之间,之后和类选项。 You can use the helper to create
<input type="button" />
elements with a good amount of flexibility. 您可以使用帮助程序创建具有良好灵活性的
<input type="button" />
元素。
you can create costum submit by this code 您可以通过此代码创建costum
echo $this->Form->submit(
'Submit',
array('div' => false,'class' => 'urclass', 'title' => 'Title')
);
This is enough: 这就够了:
echo $this->Form->submit("Custom message");
Also as @Mike suggest close the form with 同样@Mike建议关闭表格
echo $this->Form->end();
I created a custom button using an image in my under app/webroot/img that uses inline style for specifying size and changing the position to center 我使用我的under 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();
For CakePHP 2.x, you can use 对于CakePHP 2.x,您可以使用
$options = array(
'label' => 'Update',
'div' => array(
'class' => 'glass-pill',
)
);
echo $this->Form->end($options);
或者您可以将两者结合使用:
echo $this->Form->end("Custom Message");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.