Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to put a bootstrap glyphicon inside of a {{ Form::submit(' ')}} - Laravel

Tags:

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?

like image 735
Gilko Avatar asked Dec 23 '13 15:12

Gilko


People also ask

How do I add a search Glyphicon in bootstrap?

Step by step guide for the implementation: Step 1: Include Bootstrap and jQuery CDN into the <head> tag before all other stylesheets to load our CSS. Step 2: Add <div> tag in the HTML body with class container. Step 3: Now add any icon that you want using the below syntax, where the name is the name of glyphicon.

Is bootstrap a Glyphicon?

Bootstrap provides set of graphic icons, symbols and fonts called Glyphicons.

What is the main usage of Glyphicon?

The Glyphicons are a set of symbols and icons to understand more effectively and easily in web projects. The Glyphicons are used for some texts, forms, buttons, navigation, and etc. The bootstrap has many Glphyicons but there has a standard format to display icons.


2 Answers

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.

like image 61
Damien Pirsy Avatar answered Nov 02 '22 04:11

Damien Pirsy


This works for me

{{ Form::button('<span class="glyphicon glyphicon-remove"></span>', array('class'=>'btn btn-default', 'type'=>'submit')) }} 
like image 20
Ignacio Fassini Avatar answered Nov 02 '22 04:11

Ignacio Fassini