我已经设置了我的项目与客户相关的关系,我想要做的是能够通过下拉列表在我的创建项目视图中选择一个选项。
这可以这样实现:
{{ Form::select('client', array('s' => 's', 'm' => 'm'), 's');}}
但是我不确定如何从我从数据库中检索的数据动态地执行此操作,我到目前为止的代码是:
{{ Form::open(array('action' => 'ProjectController@store', 'id' => 'createproject')) }}
<div class="form-group">
<? $projects = Auth::user()->clients; ?>
@if (Auth::check())
@if (count($projects) > 0)
@foreach ($projects as $client)
{{ Form::select('client', array('client_one' => 'client_one', 'client_two' => 'client_two'), 'client_one');}}
@endforeach
@else
<h3>You have no projects click <a href="/project/create">here to create a project</a></h3>
@endif
@endif
</div>
<div class="form-group">
{{ Form::label('project_name', 'Project Name') }}
{{ Form::text('project_name', Input::old('project_name'), array('class' => 'form-control')) }}
</div>
谁能指出我如何动态填充此选择字段的方向?
提前致谢!