HelperForm
HelperForm
Form declaration
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Edit carrier'), // This is the name of the fieldset, which can contain many option fields
'image' => '../img/admin/icon_to_display.gif' // The icon must, if there is one, must be of the size 16*16
),
'input' => array(
array(
'type' => {'text', 'select', 'textarea', 'radio', 'checkbox', 'file', 'shop', 'asso_shop', 'free', 'color'},
['label'] => $this->l('Shipping method'), // Theoretically optional, but in reality each field has to have a label
'name' => 'shipping_method', // The name of the object property from which we get the value
['required'] => {true, false}, // If true, PrestaShop will add a red star next to the field
['desc'] => $this->l('Description displayed under the field'),
['hint'] => $this->l('Invalid characters:').' <>;=#{}' // This is displayed when the mouse hovers the field.
['suffix'] => 'kg' // This is displayed after the field (ie. to indicate the unit of measure)
['options'] => array( // This is only useful if type == select
'query' => $array_of_rows, // $array_of_rows must contain an array of arrays, inner arrays (rows) being mode of many fields
'id' => 'id_carrier', // The key that will be used for each option "value" attribute
),
['values'] => array( // This is only useful if type == radio
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
[is_bool] => {true, false}, // This is only useful if type == radio. It display a "yes or no" choice.
['empty_message'] => $this->l('To be displayed when the field is empty'),
['lang'] => {true, false}, // Is the field multilang?
),
array(
//another field
),
),
'submit' => array(
'title' => $this->l(' Save '), // This is the button that saves the whole fieldset.
'class' => 'button'
)
);Basic declaration
Generating specific elements
Text input
Selector
Checkbox
Radio button
Other HTML elements
Last updated
Was this helpful?
