How can I include html within a form label using Laravel Collective?

Damon picture Damon · Jan 6, 2016 · Viewed 8.4k times · Source

Reading through this SO thread I have read that I can create a new macro to create custom form inputs.

I am brand new to Laravel development (big surprise) & it seems a tad overkill for such a small thing. Is there a "simpler" way to have something like this:

blade template

{!!Form::label('firstName', 'First Name<sup>*</sup>') !!}
{!! Form::text('firstName', null, ['class'=>'required']) !!} 

html

<label for="firstName">First Name*</label>
<input type="text" name="firstName" class="required">

Or, is this a case where I just write the html, and then use the form service to create the inputs?

Thank you for your patience and insight.

Answer

Salikh Gurgenidze picture Salikh Gurgenidze · Jun 26, 2017

The simple way to do this is

{!! Form::label('labelFor','labelText',[],false) !!} 

the last parameter is $escape_html which default value is "true".