Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use <span> inside Form Label in Blade template

In html I can use <span> tag inside form label like this:

<label for="name" class="class-name">Name:<span class="required"></span></label>

Using Laravel Blade, the code for label is like this:

{!! Form::label('name','Name:',['class'=>'class-name']) !!}

How can I use <span> inside form label using blade template?

like image 548
smartrahat Avatar asked Mar 06 '16 00:03

smartrahat


People also ask

How to create a blade Template Layout in WordPress?

You will have to use the following steps to create a blade template layout − Create a layout folder inside the resources/views folder. We are going to use this folder to store all layouts together. Create a file name master.blade.php which will have the following code associated with it −

Where are blade templates stored in PHP?

Blade template files use the .blade.phpfile extension and are typically stored in the resources/viewsdirectory. Blade views may be returned from routes or controller using the global viewhelper.

What is the form attribute of a label?

The form attribute specifies the form the label belongs to. The value of this attribute must be equal to the id attribute of a <form> element in the same document. Specifies the form element the <label> element belongs to.

How do I add components to a blade application?

When writing components for your own application, components are automatically discovered within the app/View/Componentsdirectory and resources/views/componentsdirectory. However, if you are building a package that utilizes Blade components, you will need to manually register your component class and its HTML tag alias.


2 Answers

Try this one code:

{!! Html::decode(Form::label('name','Name: <span class="required"></span>')) !!}
like image 175
Ján Ambroz Avatar answered Sep 18 '22 06:09

Ján Ambroz


Just set the 4th parameter of Form::label to false which is escape_html = false.

{!! Form::label('name','Name: <span class="required"></span>', [], false) !!}
like image 28
Alex Avatar answered Sep 20 '22 06:09

Alex