doulan9287
2017-04-17 10:31
浏览 64
已采纳

在laravel表单中显示下拉值选择列表?

Here is my code:

controller file: EmergencyContactsController.php

$surnames = DB::table('salutations')->pluck('name'); 
return view('patient/emergencycontacts', ['salutation' => $surnames]);

Blade file: patient/emergencycontacts.blade.php

    {!! Form::open(array('route' => 'emergencycontacts_store', 'class' => 'form')) !!}
<div class="form-group">
{!! Form::label('Salutation') !!}
{{ Form::select('role', ['' => 'Select Role'] + $salutation, null, ['class' => 'form-control']) }}
 </div>
<div class="form-group">
{!! Form::label('First Name') !!}
{!! Form::text('firstname', null, array('required', 'class'=>'form-control', 'placeholder'=>'First Name')) !!}
</div>
<div class="form-group">
{!! Form::label('Last Name') !!}
{!! Form::text('lastname', null, array('required', 'class'=>'form-control', 'placeholder'=>'Last Name')) !!}
</div>
<div class="form-group">
{!! Form::label('Relationship') !!}
{{ Form::select('relationship', ['Father', 'Mother', 'Husband','Wife','Son','Daughter','Uncle','Aunty','Other']) }}
</div>
<div class="form-group">
{!! Form::label('Phone') !!}
{!! Form::text('phone', null, array('required', 'class'=>'form-control', 'placeholder'=>'Phone')) !!}
</div>
<div class="form-group">
{!! Form::label('Fax') !!}
{!! Form::text('fax', null, array('class'=>'form-control', 'placeholder'=>'Fax')) !!}
</div>
<div class="form-group">
{!! Form::submit('Save',array('class'=>'btn btn-primary')) !!}
</div>
{{ Form::close() }}

When I go to url http://localhost:8000/patient/emergency-contacts/create it gives me error:

"Unsupported operand types"

图片转代码服务由CSDN问答提供 功能建议

这是我的代码:

控制器文件:EmergencyContactsController.php

  $ surnames = DB :: table('salutations') - &gt; pluck('name');  
return view('patient / emergencycontacts',['salutation'=&gt; $ surnames]); 
   
 
 

刀片文件:patient / emergencycontacts.blade.php < / p>

  {!!  Form :: open(array('route'=&gt;'emergencycontacts_store','class'=&gt;'form'))!!} 
&lt; div class =“form-group”&gt; 
 {!!  Form :: label('Salutation')!!} 
 {{Form :: select('role',[''=&gt;'Select Role'] + $ salutation,null,['class'=&gt;'  form-control'])}} 
&lt; / div&gt; 
&lt; div class =“form-group”&gt; 
 {!!  Form :: label('First Name')!!} 
 {!!  Form :: text('firstname',null,array('required','class'=&gt;'form-control','placeholder'=&gt;'First Name'))!!} 
&lt; / div&gt;  
&lt; div class =“form-group”&gt; 
 {!!  Form :: label('姓氏')!!} 
 {!!  Form :: text('lastname',null,array('required','class'=&gt;'form-control','placeholder'=&gt;'姓氏'))!!} 
&lt; / div&gt;  
&lt; div class =“form-group”&gt; 
 {!!  Form :: label('Relationship')!!} 
 {{Form :: select('relationship',['Father','Mother','Husband','Wife','Son','Daughter',  '叔叔','阿姨','其他'])}} 
&lt; / div&gt; 
&lt; div class =“form-group”&gt; 
 {!!  Form :: label('Phone')!!} 
 {!!  Form :: text('phone',null,array('required','class'=&gt;'form-control','placeholder'=&gt;'Phone'))!!} 
&lt; / div&gt; \  n&lt; div class =“form-group”&gt; 
 {!!  Form :: label('Fax')!!} 
 {!!  Form :: text('fax',null,array('class'=&gt;'form-control','placeholder'=&gt;'Fax'))!!} 
&lt; / div&gt; 
&lt; div class  = “形式的基团” &GT; \ N {!  Form :: submit('save',array('class'=&gt;'btn btn-primary'))!!} 
&lt; / div&gt; 
 {{Form :: close()}} 
   
 
 

当我去网址时 http:// localhost:8000 / patient / emergency-contacts / create 它给了我错误:

“不支持的操作数类型”

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题