简体   繁体   English

从一种形式的两个提交按钮laravel php

[英]two submit buttons from one form laravel php

I want to use two submit buttons in one form. 我想以一种形式使用两个提交按钮。 this is my blade file 这是我的刀片文件

<input type="submit" id="submit" name="Submit" value="Submit">
<input type="submit" id="pay" name="Pay Now" value="Pay ">

This is the way I have declared the function in the controller 这是我在控制器中声明函数的方式

 public function postAuth()
    {  
        if(Input::get('submit')) {

            $this->postSubmit(); 
        } elseif(Input::get('pay')) {

            $this->postPay(); 
        }

    }

    public function postSubmit()
    {
        echo "We're logging in";
        return Redirect::to('/Admin/channel');
    }

    public function postPay()
    {
        echo "We're registering";
        return Redirect::to('/pay');
    }

this is my web.php 这是我的web.php

Route::post('/abc', 'channelController@postAuth');

but there's an issue with my controller function.. how should i correct it? 但是我的控制器功能有问题..我应该如何纠正呢?

Try as below... 尝试如下...

HTML 的HTML

 <input type="submit" id="submit" name="submit" value="send">
  <input type="submit" id="pay" name="submit" value="pay">

Function 功能

 public function postAuth()
    {   //return "dfsdf";
        //check which submit was clicked on
        if(Input::get('submit') == 'send') {
            return "dfgcvhbj";
            $this->postSubmit(); //if login then use this method
        } elseif(Input::get('submit') == 'pay') {
            return "sdfsdfs";
            $this->postPay(); //if register then use this method
        }

    }

I just changed the controller as shown below 我只是更改了控制器,如下所示

public function postAuth()
    {
        if (Input::get('submit') == 'send') {

            return redirect(url('/Admin/channel'));
        } elseif (Input::get('submit') == 'pay') {

            return redirect(url('/pay'));
        }

    }

First you can use jQuery validator .You can download : https://plugins.jquery.com/validation/ 首先,您可以使用jQuery验证程序。您可以下载: https : //plugins.jquery.com/validation/

Then you can remove tag and use . 然后,您可以删除标签并使用。

in submitHandler 在submitHandler中

        submitHandler: function (form) {
                                  var loading_el = $('#pay');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM