duan0708676887 2016-02-04 09:57
浏览 60
已采纳

检查是否在Laravel中单击了按钮类型=提交名称=提交

i am trying to get which button is clicked from a form. I have 3 buttons in a form here is how my view looks like:

<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>

And here is how i am checking that on my controller:

  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.

}

I am always ending up with something else. when i do the return $request->except('_token'); i get this:

{
  "pagename": "asdfasdf",
  "pagecontent": "<p>asdfasdf<\/p>
",
  "displayfrom": "2016-02-04 00:00:00",
  "submit": "",
  "metatitle": "",
  "metakeywords": "",
  "metadescription": "",
  "user": 11,
  "active": 1
}

I dont know why its not getting the value of a <button type="submit">.

Any suggestions will be helpful. Thank you!

  • 写回答

1条回答 默认 最新

  • drphfy1198 2016-02-04 10:16
    关注

    Add this in submit button value="submit"

    <button type="submit" value="submit" name="submit" class="btn green">
    <button type="submit" value="draft" name="draft" class="btn btn-warning">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?