Contact form extending
There are five files that rule the contact form:
site/plugins/zero-one/snippets/contact/form.phpThe frontend of the formControllers:
site/plugins/zero-one/controllers/contact.phpController used for the Contact template pagesite/plugins/zero-one/controllers/site.phpController used for Page Builder contact form block.
Email templates:
site/plugins/zero-one/templates/emails/email.phpPlain text email templatesite/plugins/zero-one/templates/emails/email.html.phpHTML email template
Basic knowledge needed
Before going further it is advisable that you have basic knowledge of how PHP contact forms work, and to read through these:
https://getkirby.com/docs/cookbook/forms/basic-contact-form Basic Kirby contact form
https://www.one.thezero.club/guide/theme-extending How to properly extend Zero One
New form field example
Let's say you want to add a new field "Company" to the form.
Form frontend
Copy
site/plugins/zero-one/snippets/contact/form.phpto
site/theme/snippets/contact/form.phpand open it with your code editoralso, open https://getuikit.com/docs/form page to see what frontend options are available
Every field must have these attributes:
Unique
name
value
Optional
alert
This new field won't be required, but we will create some rule for it.
Controller
Copy
site/plugins/zero-one/controllers/contact.phpTo
site/theme/controllers/contact.php
Import data
Now you must add new field data to that controller.
Add rule
Add new rule for that field.
Alert message for that rule
Add alert message for that new field.
Export data to email
And lastly, export that data to email.
Now, your new field is ready, the only thing left to do is add that data to email content.
Email content
Copy
site/plugins/zero-one/templates/emails/email.phpTo
site/theme/templates/emails/email.php
And
Copy
site/plugins/zero-one/templates/emails/email.html.phpTo
site/theme/templates/emails/email.html.php
Now add new "Company" field content to emails.
And that's it!
Your new field is connected and ready to go. You can add as many fields as you like.
Last updated
Was this helpful?