I’m using Uniform for the first time, and not changing much. It’s working well and sending my form’s three fields via email, using an email template for the body. (Easy plugin!)
It’s crucial that the resulting email sends the title of the page — they are requests for specific reports. After adding $page to the return function, I’m able to get the $page->title() in the subject option of the Email Action.
controllers/report.php [excerpt]
if ($kirby->request()->is('POST')) {
$form->emailAction([
'to' => 'request@client.com',
'from' => 'info@client.com',
'subject' => 'Report Request: ' . $page->title(),
'template' => 'report'
])->done();
Now is there any way to add the title to the body as well? I think I can convey information in a hidden form field, but that’s not ideal. And anything complex, like writing a custom action, is probably not worth the effort—or beyond my skills.
templates/emails/report.php
Somebody has requested this report:
GET TITLE AND/OR OTHER FIELDS FROM PAGE?
Name: <?= $name ?>
Company: <?= $company ?>
Email: <?= $email ?>
As it stands, the title is already being delivered. Still, I’m curious to know where to begin if I wanted to add $page information — not just the form values — to the email.
Thanks for any help.