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

Learn how to upgrade to the latest version.


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:

  • setName: Set the name of field
  • setType: Set the type of field (text, checkbox…). Read list below
  • setRequired: Set if the field is required or not
  • setLabel: Set the label of the field
  • setValue: Set the field value
  • setAvailableValues: Set the available values for the field, to select among other things
  • addAvailableValue: Add an available value for the field
  • setMaxLength: Maximum length of the field
  • setConstraint: Add a validation constraint to the field, call methods are those of the Validation class (ex isEmail)

Here are all the possible types of fields:

return [
    // Standard text field
    (new FormField)
        ->setLabel($this->trans('Your first name')),
    // File field
    (new FormField)
        ->setLabel($this->l('Upload a document')),
    // Select field
    (new FormField)
        ->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)
        ->setAvailableValues(['key' => 'value 1', 'key2' => 'value2'])
        ->setLabel($this->l('Country select')),
    // Checkbox field
    (new FormField)
        ->setLabel($this->l('Checkbox type')),
    // Radio buttons field
    (new FormField)
        ->setAvailableValues(['key' => 'value 1', 'key2' => 'value2'])
        ->setLabel($this->l('Radio buttons type')),
    // Date field
    (new FormField)
    // Birthday field
    (new FormField)
    // Password field
    (new FormField)
    // Email field
    (new FormField)
        ->setLabel($this->l('Email type')),
    // Phone field
    (new FormField)
        ->setLabel($this->l('Phone type')),
    // Hidden field
    (new FormField)
        ->setValue('My hidden value')
Next: Alter Configuration Back Office forms ›