Stat...">

Creating a form label element

How to create a form label element in laravel.

I want to convert below html

<label class="control-label">Status <span class="required">*</span></label>

I used

{!! Form::label('status', 'Status <span class="required">*</span>', array('class' => 'control-label')) !!}

But the conclusion

Status <span class="required">*</span>

The question is how to render HTML in it, or is there a way?

+4
source share
1 answer

You cannot - The Laravel Collective function Form::label runs it throughhtmlspecialchars .

However, it Form::labeljust creates HTML. You make good use of raw HTML for this - just add for="status"to associate it with the form field.

<label class="control-label" for="status">Status <span class="required">*</span></label>

You could, I suppose, run the generated label through htmlspecialchars_decode, but I think this is ugly and confusing for someone else reading your code.

{!! htmlspecialchars_decode(Form::label('status', 'Status <span class="required">*</span>', array('class' => 'control-label'))) !!}
+5
source

Source: https://habr.com/ru/post/1622827/


All Articles