【发布时间】:2017-09-05 13:43:06
【问题描述】:
程序员朋友们,您好,
我整天都很沮丧,因为我必须为我必须为我在实习的公司创建的一个小时注册应用程序制作提交表单。
所以基本上必须做什么:我已经制作了一个包含多个值的提交表单,我被要求进行一个下拉选择,我可以在其中放置“公司名称”和“任务名称”的值。 (任务与公司名称相关联)。所以基本上我想知道的是如何在一个下拉菜单中放置 2 个值。具有“$company name - $task name”的布局
create.blade.php
{!! Form::open(['url' => 'hoursregistrations/create','files'=>true]) !!}
<div class="form-group" hidden>
{!! Form::label('user_id', 'User ID: ') !!}
{!! Form::text('user_id', $authenticated, null, ['class' => 'form-control']) !!}
</div>
<select name="">
@foreach($items as $item)
<option value="{{ $item->id }}">
{{ $item->company->name }} - {{ $item->name }}
</option>
@endforeach
</select>
<div class="form-group">
{!! Form::label('note', 'Notitie: ') !!}
{!! Form::text('note', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('date', 'Datum: ') !!}
{!! Form::date('date', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('hours', 'Uren: (uren-minuten) ') !!}
{!! Form::time('hours', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<a class="btn btn-danger" href="{{ route('hoursregistrations.index') }}">
@lang('button.cancel')
</a>
<button type="submit" class="btn btn-success">
@lang('button.save')
</button>
</div>
</div>
{!! Form::close() !!}
在这段代码 sn-p 中,公司变量是 $project_id,任务 id 是 $subproject_id。
也是将数据重定向到创建视图的控制器功能
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$authenticated = Sentinel::getUser()->id;
$activity_name = Subproject::pluck('id');
$items = array(
'company_name' => Company::where('status','client')->pluck('company_name', 'id'),
'subproject_id' => Subproject::pluck('title', 'id')
);
//dd($items);
return view('hoursregistrations.create', compact('subproject_id', 'authenticated',
'company_name', 'activity_name', 'items'));
}
结论:如何将 $project_id 和 $subproject_id 合并到一个下拉项中。
p.s 如果听起来含糊不清,我很抱歉我不善于解释
【问题讨论】: