【发布时间】:2018-06-23 04:09:23
【问题描述】:
我的更新表单需要两个提交按钮,
当前设置
目前,当我点击提交时,它会保存我的数据并将我重定向到另一个页面,我可以在其中编辑我的多个图像(所以我的表单就像两步功能)
我要补充的内容
我想添加另一个按钮来保存我的数据并将我返回到索引页面(跳过第二步)
最后结果
最后的结果将是我的带有两个按钮的编辑表单
- 按钮 1 保存数据并将我返回到下一个表单以编辑我的图像
- 按钮 2 保存数据并将我返回到索引页面
代码
controller function
public function update(Request $request, $id)
{
// validation and....
$product->save();
// this is my current button action (redirect to second step)
return redirect()->route('editmultiimages',
$product->id)->with('success',
'Product, '. $product->title.' updated, now you can edit images.');
// need second button action here
}
blade form
{{ Form::model($product, array('route' => array('products.update', $product->id), 'method' => 'PUT', 'files' => true)) }}
// my inputs
// my current button (saves data and goes to next step)
{{ Form::submit('Edit Images', array('class' => 'btn btn-success')) }}
{{Form::close()}}
有什么想法吗?
【问题讨论】: