这是我的观点我有2个按钮,一个是保存并退出,另一个是保存并留在这里
查看
<button type="submit" name="submit_1"> Submit and Exit</button>
<button type="submit" name="submit_2">save and stay Here</button>
控制器
public function store(Request $request)
{
$data['name'] = $request->input('name');
$data['adr'] = $request->input('adr');
$myuser = Data::create($data);
if(Input::get('submit_1')) {
return redirect()->route('myuser.index');
} elseif(Input::get('submit_2')) {
return redirect()->route('myuser.create');
}
}
我试过这个,但它不适合我,请帮助我
答案 0 :(得分:1)
你可以尝试:
<input type='submit' name='submit' value='submit_1'>
<input type='submit' name='submit' value='submit_2'>
答案 1 :(得分:0)
试试这个:
查看强>
<button type="submit" name="submit_1" value="submit_1"> Submit and Exit</button>
<button type="submit" name="submit_2" value="submit_2">save and stay Here</button>
<强>控制器强>
public function store(Request $request)
{
if($request->get('submit_1') == "submit_1") {
return redirect()->route('myuser.index');
} else if($request->get('submit_2') == "submit_2") {
return redirect()->route('myuser.create');
}
}