Contact Form on One Page

Hello all,

I am in despair.
I am building a One Page site according to the following instructions: One-pager site | Kirby CMS. And there I have a section in which I want to display a contact form. I would like to do this according to the following instructions: Email contact form | Kirby CMS.

However, this does not really work. If I use the contact form on a “normal page”, it works. But as soon as I want to use it in a section of my one page site, it no longer works. Does anyone have any experience here?

Hey, could you please post your code and where exactly you included it?

I have included the controller as home.php. In the home.php template file I pass the controller data to my contact snippet, where my contact form is located. I did not change any in the controller or in the contact form.

`
<?php

snippet('header');

foreach($pages->listed() as $section) {
  snippet($section->uid(), ['sectiondata' => $section, 'alert' => $alert, 'data' => $data, 'success' => 
$success]);
}

snippet('footer');

?>

`

And where does the action attribute of the form go to?

The action goes to the url of the “home” page.

action="<?= $page->url() ?>

Ok, next question. What exactly is “it no longer works”? The controller doesn’t do anything at all?

What if you do a

dump($data);

right after the header snippet in the home template?

A empty pre section appers. "it no longer works” means the page is reloading but nothing happend. the “home” page is there with an empty contact formular. And MailHog doesnt show a mail.

1 Like

Hey :slight_smile: I have de same problem… have you find the solution ?
Thank you

Ok the answer to integrate form on home page is :

replace this :

<form action="<?php echo $page->url() ?>" method="POST">

by this

<form action="<?php echo $page->url() ?>/" method="POST">

I add just a " / " after my url…

Hey,

Unfortunately, this did not help me.
Have you also made the structure on the basis of the two examples?

Hello,

I have the same problem. I have also made a minimal construction based on the examples. I get the same result as Kloerdener. Does anyone have an idea?

@AlterHaudegen What exactly are you trying to do? Combine the one pager with the contact form or just integrate the form on the home page?

I am trying to integrate the contact form as a section in the one page.
I have taken the following two instructions and combined them. However, I have the same problem as Kloerdener

One-pager site | Kirby CMS .
Email contact form | Kirby CMS .

@texnixe I can upload my site folder to github, then you can take a closer look. Would that be helpful?

@AlterHaudegen Yes, that would help.

I have found the error.
My submit button did not have a “name” property.

Thank you