For the complete documentation index, see llms.txt. This page is also available as Markdown.

Contact form extending

IMPORTANT NOTE: Our free support doesn't cover help with these customisations. Especially because PHP form processing is time-consuming to debug.

But, if you need help with the integration of complex forms, you can hire us to do that for you.

Four files rule the contact form:

  1. site/plugins/zero-one/snippets/contact/form.php The frontend of the form

  2. Controllers:

    • site/plugins/zero-one/controllers/site.php The controller used the contact form.

  3. Email templates:

    • site/plugins/zero-one/templates/emails/email.php Plain text email template

    • site/plugins/zero-one/templates/emails/email.html.php HTML 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:

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.php

  • to site/theme/snippets/contact/form.php and open it with your code editor

  • Also, 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 a new rule for it.

Controller

  • Copy site/plugins/zero-one/controllers/site.php

  • To site/theme/controllers/site.php

Import data

Now you must add new field data to that controller.

Add rule

Add a new rule for that field.

Alert message for that rule

Add an 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 the email content.

Email content

  • Copy site/plugins/zero-one/templates/emails/email.php

  • To site/theme/templates/emails/email.php

And

  • Copy site/plugins/zero-one/templates/emails/email.html.php

  • To 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