Two different forms on the same page

Hi, what should be the controller, if I want to have two different forms on the same page. Actually forms are very similar, only one type of form is used to send emails to page admin, and another to user, who submitted the form (to get PDF catalog).

Now I am using same method as here Email contact form | Kirby CMS

I don’t understand why that would be two forms? Or do you mean two actions for the same form?

Like I wrote, one form is contact form to send inquiry, another form is to get PDF catalog. So should be two separate forms with different actions - one to send email to admin, another - to send email to visitor, who filled the form.

Both form handlers can be in the same controller, you only have to use different submit values so you can differentiate which form was submitted.

Thanks, can you help how to do this?

Your submit button always has a name e.g.

            <input type="submit" name="submit" value="Submit">

So you give your submit buttons different names (form_a, form_b), and then in your controller check with an if statement, which for was submitted.

if($kirby->request()->is('POST')) {
  if (get('form_a')) {
    // do stuff when form_a was submitted
 if (get('form_b')) {
  // do stuff when form_b was submitted

Clear, thank you very much, already implemented :wink: