New fields in contact form

We´ll see how to add a new field in the contact form

The first thing we´ll do is find the file


In this function

public function postProcess()

and add these

$full_name = Tools::getValue('full_name');

We want to make this a required field so we have to validate it by adding this code in the same function

else if (!$full_name)
$this->errors[] = Tools::displayError('The full name cannot be blank.');

At the end of the function, in part

'{full_name}' => $full_name,

Then look for the function

public function initContent()

and add these

$full_name= Tools::safeOutput(Tools::getValue('full_name',
((isset($this->context->cookie) && isset($this->context->cookie->customer_firstname) && Validate::isName($this->context->cookie->customer_firstname)) ? $this->context->cookie->customer_firstname.' '.$this->context->cookie->customer_lastname : '')));

and in


add these

'full_name' => $full_name,

This code is to complete and validate the field if the user is logged

The next thing we need to do is find the file


and add this

<p class="form-group"> <label for="full_name">{l s='Full name'} <sup class="required">*</sup> :</label> <input class="form-control validate" type="text" id="full_name" name="full_name" data-validate="isName" value="{$full_name}" /> </p>




The last step is to add the variable in the mail template

<span style="color:#333"><strong>Name:</strong></span> {full_name}<br /><br />







Posted on 21/02/2015 in Design, Prestashop

Share the Story

About the Author

Leave a reply

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Back to Top