Warning: You are browsing the documentation for PrestaShop 1.7, which is outdated.
You might want to read an updated version of this page for the current version, PrestaShop 8. Read the updated version of this page
From PrestaShop 1.7, fields are managed in FormField class and display is set in themes/<themeName>/templates/_partials/form-fields.tpl
template.
The useful methods to manage this fields are:
Here are all the possible types of fields:
<?php
return [
// Standard text field
(new FormField)
->setName('first_name')
->setType('text')
->setRequired(true)
->setValue("John")
->setMaxLength("128")
->setLabel($this->trans('Your first name')),
// File field
(new FormField)
->setName('file_upload')
->setType('file')
->setLabel($this->l('Upload a document')),
// Select field
(new FormField)
->setName('select_field')
->setType('select')
->setAvailableValues(['key' => 'value 1', 'key2' => 'value2'])
->setLabel($this->l('Select type')),
// Country select field (like select but add a 'js js-country' class)
(new FormField)
->setName('country_field')
->setType('countrySelect')
->setAvailableValues(['key' => 'value 1', 'key2' => 'value2'])
->setLabel($this->l('Country select')),
// Checkbox field
(new FormField)
->setName('checkbox_field')
->setType('checkbox')
->setValue(1)
->setLabel($this->l('Checkbox type')),
// Radio buttons field
(new FormField)
->setName('radio_field')
->setType('radio-buttons')
->setAvailableValues(['key' => 'value 1', 'key2' => 'value2'])
->setLabel($this->l('Radio buttons type')),
// Date field
(new FormField)
->setName('date_field')
->setType('date')
->setLabel($this->l('Date')),
// Birthday field
(new FormField)
->setName('birthday_field')
->setType('birthday')
->setLabel($this->l('Birthday')),
// Password field
(new FormField)
->setName('password_field')
->setType('password')
->setLabel($this->l('Password')),
// Email field
(new FormField)
->setName('email_field')
->setType('email')
->setLabel($this->l('Email type')),
// Phone field
(new FormField)
->setName('phone_field')
->setType('phone')
->setLabel($this->l('Phone type')),
// Hidden field
(new FormField)
->setName('hidden_field')
->setType('hidden')
->setValue('My hidden value')
];