创建窗体标签元素



如何在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'))) !!}

最新更新