How to add Glyphicon to {{!! Form::Button !!}}

828 views Asked by At

I'm using Laravel 5.0 and have the following problem.

This is my button:

{!! Form::button('Delete', array('class' => 'btn btn-sm btn-danger', 'data-toggle' => 'modal', 'data-target' => '#'.$category->id)) !!} 

How can I add something like this:

<span class="glyphicon glyphicon-trash"></span>   

I'm came across to this -> Is it possible to put a bootstrap glyphicon inside of a {{ Form::submit(' ')}} - Laravel but it is for the notation wihtout exclamation marks (It does not work for me).

2

There are 2 answers

3
Geoffrey On

I don't know Laravel, so I don't know how it taps into CSS. If I were to do it in an HTML/CSS environment, I would do the example below using Pesudo Classes.

.btn-danger:before {font-family:'Glyphicons Halflings';content:"\e020"} 
<button class="btn btn-sm btn-danger"> Blah</button>

You don't have to use .btn-danger, instead use the class/Id that you are attaching to the button.

JSFiddle

0
jpradcliffe On

This will do the trick:

{{ Form::button('', ['type' => 'submit', 'class' => 'btn btn-danger glyphicon glyphicon-remove']) }}