我正在尝试从表单中单击哪个按钮。我在表单中有3个按钮就是我的视图:
<div class="form-actions">
<button type="submit" name="submit" class="btn green"><i class="fa fa-check"></i> Submit</button>
<button type="submit" name="draft" class="btn btn-warning"><i class="fa fa-paper-plane-o"></i> Draft</button>
<button type="submit" name="Trash" class="btn red"><i class="fa fa-trash-o"></i> Trash</button>
</div>
以下是我在我的控制器上检查的方法:
if(Button::get('submit')) {
$request['status'] = 1;
}
elseif(Input::has('draft')) {
$request['status'] = 2;
} else {
return "something else"; //i am ending us with this all the time.
}
我总是以something else
结尾。当我做return $request->except('_token');
我得到这个:
{
"pagename": "asdfasdf",
"pagecontent": "<p>asdfasdf<\/p>\r\n",
"displayfrom": "2016-02-04 00:00:00",
"submit": "",
"metatitle": "",
"metakeywords": "",
"metadescription": "",
"user": 11,
"active": 1
}
我不知道为什么它没有得到<button type="submit">
的价值。
任何建议都会有所帮助。谢谢!
答案 0 :(得分:3)
在提交按钮value="submit"
<button type="submit" value="submit" name="submit" class="btn green">
<button type="submit" value="draft" name="draft" class="btn btn-warning">