How to configure the contact form
To configure the contact form you will need to edit the contact form’s html markup in both or either
We are providing the default field in the contact form that you can use as is or you can modify it to suit your needs. If you want to modify the markup you will need to take into consideration the input format that is described in the “form.php” file.
The input we are providing by default are:
You can find this list in the “form.php” file. If you need to add more fields than these, you can extend this list and add your own, for example let’s add a new email input, such as email confirmation. The updated code will look like this:
<?php /* * Fields configuration for validation */ $fieldsConfig = array( 'input_username' => array('value_not_empty' => 'Please specify a value for the Name field' ), 'input_phone' => array('value_not_empty' => 'Please specify a value for the Phone field' ), 'input_email' => array( // FUNCTION_NAME => ERROR_MESSAGE 'value_not_empty' => 'Please specify a value for the Email field', 'is_valid_email' => 'Please enter a valid email', ), 'input_email_2' => array( // FUNCTION_NAME => ERROR_MESSAGE 'value_not_empty' => 'Please specify a value for the email confirmation field', 'is_valid_email' => 'Please enter a valid email', ), 'input_message' => array( 'value_not_empty' => 'Please enter a message', ), );
You will also have to update the html markup of the form to add your new input. The validation will be handled server-side using the validation rules that you set for that field.
You will also need to include this new field in the output mail message if you need it.
You can access the form fields using this variable:
$postFields; this variable will contain all form fields that have a name attribute.
The updated code for the email message would look like this:
<?php $subject = $emailSubject; $message = '<div>'; $message .= $postFields['input_message']; $message .= '<div> Confirmation email: '.$postFields['input_email_2'].'</div>'; $message .= '</div>'; // Existent code here //....
How to enable the contact form functionality#
By default the contact form needs to be configured, and you will have to edit the “form.php” file to configure the email address where you want emails to be sent (the
$recipientEmailAddress variable) and your name that will be used when sending the email (the
Optionally you can configure the list of allowed html tags that you want to accept in the email content by editing the
You can also enable debugging while testing the contact form functionality by editing the
$debug variable. Enabling it will allow you to see any errors that might need to be corrected before you enable the contact form to your visitors.
Ho to setup the email message and thank you message#
Edit the “form.php” file and locate these two variables at the top of the file:
You can configure the email subject by prefixing any of the fields name with an
@ symbol. For example:
<?php $emailSubject = 'You have been contacted by @input_username';
@input_username placeholder will be replaced with the value the visitor will enter in the user name field of the contact form.
Please note that the thank you message does not allow that functionality, so the text will be displayed as you enter it.
You will find many comments in the “form.php” file and you can follow the pointers to configure it to suit your needs. We’ve tried to make this process as easy as possible even for non-coders, but should you need any help configuring it we will be here to help you out.