4

I have this form

        <div class="row">
            <div class="col-lg-8 offset-2">
                <form class="form-signin" method="POST">
                    {{ csrf_field() }}
                <div class="form-label-group mt-1">
                    <label class="text-dark-orange" for="name">Naam</label>
                    <input type="text" id="name" name="name" class="form-control sentje-inputfield-payment" placeholder="Vul hier uw naam in" required>
                </div>
                <div class="form-label-group mt-1">
                    <label class="text-dark-orange" for="note">Notitie</label>
                    <textarea type="text" id="note" name="note" class="form-control sentje-inputfield-payment" placeholder="Vul hier eventueel een notitie in"></textarea>
                </div>
            </div>
        </div>
        <div class="row mt-5">
            <div class="col-lg-8 offset-2">
                <a href="{{ route('paymentrequest.preparePayment', [$paymentrequest->unique_link, $paymentrequest]) }}"><button type="submit" class="btn btn-block btn-lg sentje-button">Betalen</button></a>
                </form>
            </div>
        </div>

When I click the button it sends the $paymentrequest with it. (I already sent that parameter to the view) How would I also pass on the data that has been putted in the form?

1 Answer 1

1
  1. Give your form an ID and make the action that of the <a> URL:

    <form action="{{ route('paymentrequest.preparePayment', [$paymentrequest->unique_link, $paymentrequest]) }}" id="my-form" class="form-signin" method="POST">
    
  2. Change your <a> to just button with the type="submit" and a form="<form-id>"

    <button type="submit" form="my-form" class="btn btn-block btn-lg sentje-button">Betalen</button>
    

Using the form property allows you to close your form tag and keep the button outside and allows you to still submit it and keep your code neater.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.