Thanks @mzur for the clarification.
I have made some changes to my controller, but am now hitting an issue where my success conditional as part of the page the form is on is now not working. This is my updated controller, using the withoutRedirect
and also flashing:
<?php
use Uniform\Form;
return function ($kirby,$page,$site,$pages)
{
$shared = $kirby->controller('site' , compact('page', 'pages', 'site', 'kirby'));
$form = new Form([
'email' => [
'rules' => ['required', 'email'],
'message' => 'Please enter a valid email address',
],
'name' => [
'rules' => ['required'],
'message' => 'Please enter your name',
],
'phone' => [],
'message' => [
'rules' => ['required'],
'message' => 'Please enter a message',
],
]);
if ($kirby->request()->is('POST')) {
if (get('formid') === 'enquiry') {
$form->honeypotGuard()->honeytimeGuard([
'key' => c::get('uniform.honeytime.key'),
'seconds' => 3,
])->withoutRedirect()->emailAction([
'to' => 'info@website.com',
'from' => 'no-reply@' . Url::host(),
'subject' => 'New enquiry form submission on ' . $site->title(),
'template' => 'simple-artwork',
'data' => [
'artwork' => $page->title() . " by " . $page->parent()->title()
]
]);
}
if($form->success()) {
flash('name', $form->data('name'));
go($page->url());
}
}
return A::merge($shared,compact('form'));
};
With this I am getting validation as expected, and also the email is sending. However after the redirect my following conditional statement isn’t working:
<?php if($form->success()): ?>
<p>Thank you <?= flash('name') ?> for your enquiry</p>
<?php endif; ?>
I guess this is to do with the redirect? I really appreciate your help so far, could you advise what I need to do here to get this to work?