Malvinka
Malvinka

Reputation: 1379

How to pass the arguments to the request from the form template

I'd like to pass additional argument next (it should be endpoint) to the request when submitting the form. I've tried: <form method="post" action="" next="/apply"> but it doesn't work. Later when receiving the form I just need to read it from request.args. How to do it correctly?

Upvotes: 1

Views: 445

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169264

You can use a hidden form field.

  <form method="post" action="">
    <input type="hidden" name="next" value="/apply">
    <!-- the rest of your form code -->

In your Flask function:

    next = request.form.get('next')

Upvotes: 1

Related Questions