I’m currently updating my site from Kirby 2 to Kirby 3.
Most of the stuff worked well thanks to the upgrade guide but now i’m struggling with the Uniform plugin.
I tried to migrate a simple contact form from Uniform 3 to Uniform 4. When I post the form i’m getting the following error:
Invalid input for prop “from”, expected string or “Kirby\Cms\User” object or collection
My controller looks as following:
<?php
use Uniform\Form;
return function ($kirby)
{
$form = new Form([
'name' => [],
'email' => [],
'telephone' => [],
'contacttype' => [],
'message' => [],
]);
$siteUrl = $kirby->site()->url();
if(strpos($siteUrl, 'localhost') == false && strpos($siteUrl, '.local') == false && strpos($siteUrl, 'staging') == false):
$emailTo = $kirby->site()->adminEmailTo();
else:
$emailTo = $kirby->site()->adminStageEmailTo();
endif;
if ($kirby->request()->is('POST')) {
$form->emailAction([
'to' => $emailTo,
'from' => $kirby->site()->adminEmailFrom(),
'subject' => t(getCurrentSite() . '-contact-request'),
])
->logAction([
'file' => kirby()->roots()->site().'/messages.log'
]);
}
return compact('form');
};
?>
When I hard code the values for from and to, then the email gets sent correct.
However, when I echo $emailTo or $kirby->site()->adminEmailFrom() infront of the emailAction, i get the proper values in there.
Any ideas where this breaks?
Thanks in advance!