我在Laravel 5中使用Laravel / Collective作为表单助手,但是当我创建表单时,它只输出html标记而不是预期的表单控件。
我添加了" laravelcollective / html":" ~5.0"到我的composer.json,运行作曲家更新。
添加' Collective \ Html \ HtmlServiceProvider'到config.app中的providers数组和' Form' => '集体\ HTML \ FormFacade''的Html' => '集体\ HTML \ HtmlFacade'在config.app文件中的别名数组中。
我的表单代码: {! Form :: model($ currency,[' route' => [' currency.update',$ currency-> id],'方法' => ;' PUT'])!!}
{{ Form::label('currency', 'Currency Code: ', ['class'=>'col-sm-3 control-label']) }}
{{ Form::text('currency', null, ['class'=>'form-control']) }}
{{ Form::label('description', 'Currency Description: ', ['class'=>'col-sm-3 control-label']) }}
{{ Form::text('description', null, ['class'=>'form-control']) }}
{{ Form::label('is_active', 'Is Active? ', ['class'=>'col-sm-3 control-label'])}}
{{ Form::checkbox('is_active', $currency->is_active) }}
{{ Form::button('Submit') }}
{!! Form::close() !!}
输出是html标记:
<label for="currency" class="col-sm-3 control-label">Currency Code: </label> <input class="form-control" name="currency" type="text" value="GBP" id="currency"> <label for="description" class="col-sm-3 control-label">Currency Description: </label> <input class="form-control" name="description" type="text" value="British Pound" id="description"> <label for="is_active" class="col-sm-3 control-label">Is Active? </label> <input name="is_active" type="checkbox" value="0" id="is_active"> <button type="button">Submit</button>
&#13;
我知道这可能是我想念的傻事,但到目前为止我一直很难过,任何帮助或建议都会受到赞赏。谢谢
答案 0 :(得分:0)
我的猜测是laravel正在逃避输出。尝试将代码包装在{!!改为!!}标签。
像这样:
{!! Form::label('currency', 'Currency Code: ', ['class'=>'col-sm-3 control-label']) !!}
{!! Form::text('currency', null, ['class'=>'form-control']) !!}