php 是否可以在 {{ Form::submit(' ')}} - Laravel 中放置引导程序字形
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20746049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to put a bootstrap glyphicon inside of a {{ Form::submit(' ')}} - Laravel
提问by Gilko
I want to change this:
我想改变这个:
{{ Form::submit('Delete this User', array('class' => 'btn btn-warning')) }}
to something like this:
像这样:
{{ Form::submit('<i class="glyphicon glyphicon-delete"></i>', array('class' => '')) }}
I know that the second option isn't correct, anyone knows how to write it in a correct way?
我知道第二个选项不正确,有人知道如何以正确的方式编写它吗?
回答by Damien Pirsy
Use a <button>of type submit, which adds more flexibility then a submit input:
使用<button>类型提交,这比提交输入增加了更多的灵活性:
{{Form::button('<i class="glyphicon glyphicon-delete"></i>', array('type' => 'submit', 'class' => ''))}}
To make it clear, this is the class method:
为了清楚起见,这是类方法:
public function button($value = null, $options = array())
{
if ( ! array_key_exists('type', $options) )
{
$options['type'] = 'button';
}
return '<button'.$this->html->attributes($options).'>'.$value.'</button>';
}
As you can see, $valueholds anything you put inside the <button>tag, so placing the icon there should work - I use this with Fontawesome icons and it works fine, I personally tend to use those instead of Glyphicon but the principle remains the same.
正如您所看到的,$value包含您放入<button>标签中的任何内容,因此将图标放置在那里应该可以工作 - 我将它与 Fontawesome 图标一起使用并且效果很好,我个人倾向于使用它们而不是 Glyphicon,但原理保持不变。
By using Form::submit(), instead, you create an <input type="submit"which cannot accept html as content of the valueattribute, that's why your solution won't work.
Form::submit()相反,通过使用,您创建了一个<input type="submit"不能接受 html 作为value属性内容的内容,这就是您的解决方案不起作用的原因。
回答by Ignacio Fassini
This works for me
这对我有用
{{ Form::button('<span class="glyphicon glyphicon-remove"></span>', array('class'=>'btn btn-default', 'type'=>'submit')) }}
回答by sogeniusio
I used Html::linkRoutesto create a button and cannot implement the methods you guys mentioned before... Any one have any guesses? Heres my code:
我Html::linkRoutes以前做的一个按钮,不能实现你们之前提到的方法...有没有人有任何猜测?这是我的代码:
<div class="col-md-12">
{{ Html::linkRoute('posts.index', '<< Back to blog', [], ['class' => 'btn2 btn2-default']) }}
</div>
回答by Robert Nicjoo
You can add your icon class to your class array like:
您可以将图标类添加到类数组中,例如:
array('class' => 'btn btn-primary glyphicon glyphicon-remove');

