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?
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 −
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.
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.
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.
Try this one code:
{!! Html::decode(Form::label('name','Name: <span class="required"></span>')) !!}
Just set the 4th parameter of Form::label to false which is escape_html
= false.
{!! Form::label('name','Name: <span class="required"></span>', [], false) !!}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With