我正在尝试使用输入重定向回去,但是没有将数据放回输入控件中。我是否在输入值中缺少输出指令?如果是这样,我认为要执行此操作的代码是什么?
$validator = Validator::make($request->all(), [
'owner_firstname' => 'required|min:2|max:30',
'owner_lastname' => 'required|min:2|max:30',
'partner_firstname' => 'required|min:2|max:30',
'partner_lastname' => 'min:2|max:30',
'baby_firstname' => 'min:2|max:30',
'baby_lastname' => 'min:2|max:30',
'month' => 'not_in:0',
'day' => 'not_in:0',
'year' => 'numeric|digits:4',
'guests_message' => 'required|min:30|max:5000'
]);
if ($validator->fails()) {
return redirect()->back()
->withErrors($validator)
->withInput();
}
<input type="text" id="owner_firstname" value="{{ what do I put here }}">
答案 0 :(得分:1)
您必须使用old
帮助程序来还原以前的值,并向输入中添加name
属性。
<input type="text" id="owner_firstname" name="owner_firstname" value="{{ old('first_name') }}">