是否可以在{{Form :: submit('')}}中放置引导图形 - Laravel [英] Is it possible to put a bootstrap glyphicon inside of a {{ Form::submit(' ')}} - Laravel

查看:176
本文介绍了是否可以在{{Form :: submit('')}}中放置引导图形 - Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  {{Form :: submit('Delete this User',array('class '=>'btn btn-warning'))}} 

p>

  {{Form :: submit('< i class =glyphicon glyphicon-delete>< / i>' array('class'=>''))}} 

我知道第二个选项isn 't正确,任何人都知道如何以正确的方式编写它? 使用<

  {{Form: :'('type'=>'submit','class'=>''))}} $ b: $ b  

为了说清楚,这是类方法:

  public function button($ value = null,$ options = array())
{
if(!array_key_exists('ty pe',$ options))
{
$ options ['type'] ='button';
}

return'< button'。$ this-> html-> attributes($ options)。'>'。$ value。'< / button>' ;

$ / code>

正如您所见, $ value 包含任何你放在<按钮> 标签内的任何东西,所以将图标放在那里应该可以工作 - 我将它与Fontawesome图标一起使用,并且它工作正常,倾向于使用那些而不是象形文字,但原则保持不变。

通过使用 Form :: submit()而是创建一个< input type =submit,它不能接受HTML作为属性的内容,这就是为什么你的解决方案无法正常工作。


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?

解决方案

Use a <button> of type submit, which adds more flexibility then a submit input:

{{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, $value holds 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.

By using Form::submit(), instead, you create an <input type="submit" which cannot accept html as content of the value attribute, that's why your solution won't work.

这篇关于是否可以在{{Form :: submit('')}}中放置引导图形 - Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆