2016-09-26 180 views
0

我使用Laravel/Collective作爲Laravel 5中的表單助手,但是當我創建我的表單時,它僅輸出html標記,而不是預期的窗體控件。Laravel 5 - Laravel Collective

我在我的composer.json中添加了「laravelcollective/html」:「〜5.0」,運行了作曲家更新。

在config.app和'Form'=>'Collective \ Html \ FormFacade','Html'=>'Collective \ Html \ HtmlFacade'中爲供應商數組添加了'Collective \ Html \ HtmlServiceProvider'別名數組在config.app文件中。

我的表格代碼: {!形式::模型($貨幣,[ '路線'=> [ '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>

我知道它可能是一些愚蠢的我錯過了,但我一直難倒到目前爲止,任何幫助或建議,將不勝感激。謝謝

回答

0

我的猜測是laravel正在逃避輸出。嘗試在{!中包裝你的代碼! !!}代替。

像這樣:

{!! Form::label('currency', 'Currency Code: ', ['class'=>'col-sm-3 control-label']) !!} 
{!! Form::text('currency', null, ['class'=>'form-control']) !!}