我想确保当用户单击“保存”按钮时,下拉列表中选择的值会正确传递,然后保存在控制器中。现在,当我单击“保存”时,第一个下拉列表的值未传递
控制器
public function store(Request $request)
{
$this->validate($request, [
'IncomeExpense'=>'required',
'SumOfMoney'=>'required',
]);
//Create Income
$incexp= new IncomeExpenses();
$incexp->IncomeExpense=$request->input('IncomeExpense');
$incexp->IncomeId=$request->input('IncomeId');
$incexp->ExpenseId=$request->input('ExpenseId');
$incexp->SumOfMoney=$request->input('SumOfMoney');
$incexp->Comments=$request->input('Comments');
$incexp->save();
return redirect('/incexp')->with('success', "Created");
}
查看
{!! Form::open(['action'=>'IncomeExpenseController@store', 'method' =>'POST']) !!}
<div class="form-group">
{{Form::label('IncomeExpense', 'Income&Expense')}}
{{Form::select('IncomeExpense', array( 'Expense', 'Income'),null,['class'=>'form-control'])}}
</div>
<div class="form-group">
{{Form::label('', 'Income')}}
{{Form::select('IncomeId', $income,null,['class'=>'form-control'])}}
</div>
<div class="form-group">
{{Form::label('', 'Expense')}}
{{Form::select('ExpenseId', $expense,null,['class'=>'form-control'])}}
</div>
{{Form::submit('Create', ['class'=>'btn btn-primary'])}}
{!! Form::close() !!}