Hi all - using Uniform and trying to find if there’s a way to label a field to something other than the id for more readable confirmation emails. So for example, the controller below results in a confirmation email sent where ‘firstName’ is written in the body. I would love to be able to define a readable label for it in the controller but can’t find anything in the docs. Of course I can’t use ‘First Name’ in the ID due to the spaces, but maybe I’m missing something. Thanks
<?php
use Uniform\Form;
return function ($kirby)
{
$form = new Form([
'firstName' => [],
'email' => [
'rules' => ['required', 'email'],
'message' => 'Please enter a valid email address',
],
'message' => [
'rules' => ['required'],
'message' => 'Please enter a message',
],
]);
if ($kirby->request()->is('POST')) {
$form->emailAction([
'to' => 'name@email.com',
'from' => 'name@email.com',
]);
}
return compact('form');
};
Thanks - struggling a bit with this though. I cannot find anywhere in the documentation that’s mentioned and can’t see an example of renaming a field in the email templates. My paygrade may not bridge the gap on this unfortunately and was hoping it might be a little more simple.
So it takes the fieldname, capitalizes the first letter and then the value.
I
The fieldname comes from your form, so you could either rename those fields in the form, or you create an array in your config, where you could then map those fields to something more useful:
When you say it takes the field name, do you mean ID? It would be great if I could just said the input name in the markup to name="first name" but this doesn’t work, returning nothing in the email. The constructor in the config seems based on the ID, which can’t have whitespace.
So I then have tried your suggestion, but no luck unfortunately.
This array must go in your config.php, don’t touch the plugin. And don’t edit the default snippet, but put a copy into your /site/templates/emails folder.