P-Torres
1 year ago

Disabling submit buttons. What shall I return?

Posted 1 year ago by P-Torres

I get "Missing return statement" (PHPStorm).

I have a form with two submit buttons "Update & Reload" and "Update"

The following works (in edit form):

<div class="btn-group" role="group" aria-label="">
    <button type="submit" class="btn btn-info" name="update-and-reload" value ="update-and-reload">
        Update & Reload
    </button>
    <button type="submit" class="btn btn-primary" name="update" value="update">
        Update
    </button>
</div>
    

My Controller

public function update(ArticleRequest $request, $id)
    {
        ... some code...


        if (Input::get('update-and-reload')) {

            $article->update($request->all());

            return back();

        } else if (Input::get('update')) {

            $article->update($request->all());

            return redirect()->route('articles.index');

        }

    }

But, when implementing the following to disable the buttons once clicked, it fails...

After submitting I get a blank page!

<script>
        $('form').submit(function (event) {
            $(this).find(':submit').attr("disabled", true));
        });
</script>

Any suggestions are appreciated. Thank you.

Please sign in or create an account to participate in this conversation.