I’m currently tinkering with contact form as described in Cookbook, it works almost everything as expected.
The contact form is a booking form for online apointments, the form generates a unique video conference link and password for user and client. The data is being shown in confirmation page and sent via mail.
Sometimes our clients don’t want to share e-mail, they only need to have conference link (that is OK for us too, some clients don’t want to enter the mail because of privacy reasons).
Now here is my question, how should I modify the controller to allow e-mail to be optional? Probably something in ‘to’ line should be changed? Currently, it looks like this:
$kirby->email([ 'template' => 'text-client', 'from' => 'email@example.com', 'to' => $data['email'], 'subject' => 'Online-Beratung beim XXXXX - Ihre Anfrage für ' . $page->date()->toDate('%d %B %Y'), 'data' => [ 'date' => $page->date()->toDate('%d %B %Y'), 'timeframe' => $page->timeframe(), 'name' => get('name'), 'vorname' => get('vorname'), 'company' => get('company'), 'sbausweis' => get('sbausweis'), 'arbeitssituation' => get('arbeitssituation'), 'beratungsform' => get('beratungsform'), 'beratungdgs' => get('beratungdgs'), 'email' => get('email'), 'message' => get('message'), 'panelurl' => $page->panel()->url(), 'randomizer' => md5(str::slug($data['name'] . $akt_microtime)) ] ]);
In this current state, the contact form outputs error when mail is not entered and expect the user to enter mail.