Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How insert raw HTML to label?

Is there some easy way how put raw HTML tag to label? I have this:

{{ Form::label('firstName', 'First name <em>*</em>', array('class' => 'input_tag')) }}

and it produces:

<label class="input_tag" for="firstName">First Name &lt;em&gt;*&lt;/em&gt;</label>

BUT tag EM is not interpreted as it should be. What I want is:

<label class="input_tag" for="firstName">First Name <em>*</em></label>
like image 962
Lajdák Marek Avatar asked May 17 '13 15:05

Lajdák Marek


2 Answers

use HTML::decode():

{!! HTML::decode(Form::label('firstName', 'First name <em>*</em>', array('class' => 'input_tag'))) !!}
like image 148
Aureliano Far Suau Avatar answered Oct 08 '22 19:10

Aureliano Far Suau


Using sprintf in a macro is much faster than redecoding:

Form::macro('rawLabel', function($name, $value = null, $options = array())
{
    $label = Form::label($name, '%s', $options);

    return sprintf($label, $value);
});
like image 31
Adam Rivers Avatar answered Oct 08 '22 18:10

Adam Rivers