Hello all,
I am struggeling getting two uniform forms on one page.
Does someone already managed to have solution with two forms and is able to share them.
This is how my controller looks currently (but currently no action gets exececuted)
return function ($site, $pages, $page)
{
$gb_form = new Form([
'email' => [
'rules' => ['required', 'email'],
'message' => 'Email ist eventuell fehlerhaft oder nicht vorhanden.',
],
'message' => [
'rules' => ['required'],
'message' => 'Nachricht wird benötigt',
],
'name' => [
'rules' => ['required'],
'message' => 'Name wird benötigt',
],
]);
$contact_form = new Form([
'email' => [
'rules' => ['required', 'email'],
'message' => 'Email ist eventuell fehlerhaft oder nicht vorhanden.',
],
'message' => [
'rules' => ['required'],
'message' => 'Nachricht wird benötigt',
],
'name' => [
'rules' => ['required'],
'message' => 'Name wird benötigt',
],
]);
if (r::is('POST')) {
if ($gb_form->successful()) {
$gb_form->logAction([
'guestbook-dir' => kirby()->roots()->content().'/guestbook',
]);
} elseif ($contact_form->successful()) {
$contact_form->emailAction([
'to' => 'me@example.com',
'from' => 'info@example.com',
]);
}
}
return compact('gb_form', 'contact_form');
};