1

I have a form with buttons "Accept" and "Decline". When I submit form I'd like to see if order was accepted or declined. I know how it should be done, but for some reason it wasn't not working.

FORM:

<form action="{{ url('edi')}}/lv/{{ $customer->name }}" method="POST" class="form-inline"> {{ csrf_field() }} <input type="hidden" name="file" value="{{ $edifile }}"> <input type="hidden" name="doctype" value="order"> <select name="ordertype" class="form-control"> ... </select> <input type="submit" class="btn btn-warning" name="accept" value="Accept order"> <input type="submit" class="btn btn-danger" name="decline" value="Decline order" onclick="confirm('Are you sure you want to DECLINE this order!');"> </form> 

Request parameter bag:

+request: ParameterBag {#41 ▼ #parameters: array:4 [▼ "_token" => "bW5ancRgkgvFovCeQuVxzOiXIu75ng6zl5NYlEyc" "file" => "ORDER_20170706122126714_P2576090-1.xml" "doctype" => "order" "ordertype" => "0" ] } 

As you see there is no submit button name in request.

1 Answer 1

2

While I was writing this question I found problem myself:

Basically problem was that when ever form is submitted we have a script that disables all submit buttons in form so user can't submit same form twice. All sounds fine until we understand - disabled elements aren't submitted"

Solution:

I changed script so that it would create input type="hidden" with name of originally pressed button.

P.S. Accepted answer has a good "rule of thumb" in it and I have read it and you you should too if you haven't already: How can I tell which button was clicked in a PHP form submit?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.