如何在laravel中创建表单标签元素。
我想转换以下html
<label class="control-label">Status <span class="required">*</span></label>
我使用
{!! Form::label('status', 'Status <span class="required">*</span>', array('class' => 'control-label')) !!}
但是输出是
Status <span class="required">*</span>
问题是如何在其中呈现HTML,或者有办法吗?
您不能-Laravel Collective的Form::label
函数通过htmlspecialchars
运行它。
也就是说,Form::label
只是生成HTML。使用原始HTML就可以了——只需添加一个for="status"
将其链接到表单字段即可。
<label class="control-label" for="status">Status <span class="required">*</span></label>
我想,您可以通过htmlspecialchars_decode
运行生成的标签,但我认为这对阅读您的代码的其他人来说更丑陋、更困惑。
{!! htmlspecialchars_decode(Form::label('status', 'Status <span class="required">*</span>', array('class' => 'control-label'))) !!}