...
Code Block |
---|
$this->fields_options = array( 'general' => array( ['title'] => $this->l('Carrier options'), // Th title of the fieldset. If missing, default is 'Options'. ['top'] => $this->l('Text to display before the fieldset'), // This text is display right above the first. Rarely used. ['image'] => 'url to icon', // If missing, will use the default icon for the tab. ['description'] => $this->l('Display as description'), // Displays an informational box above the fields. ['info'] => $this->l('Display as info'), // Displays an unstyled text above the fields. 'fields' => array( // The various option fields. 'PS_CARRIER_DEFAULT' => array( // The aray is named after the option's ID. It must be the same name as // the value stored in the ps_configuration table. ['title'] => $this->l('Default carrier:'), // The name of the option. ['desc'] => $this->l('The default carrier used in shop'), // The description of the option. ['cast'] => 'intval', // Using this option, you can cast the variable's content into a known value. // You can use boolval, floatval, intval or strval depending on value type you want to receive. 'type' => {'text', 'hidden', 'select', 'bool', 'radio', // The kind of input field you want to use. 'checkbox', 'password', 'textarea', 'file', 'textLang', 'textareaLang', 'selectLang'}, ['suffix'] => 'kg', // Display after the field (ie. currency)', // Only for text field or password field. ['identifier'] => 'id_carrier', // The unique ID for the form. ['list'] => array(list do display as options), // OnlyFor forselect selectfield only. ['empty_message'] => $this->l('Display if list is empty'), // OnlyFor for select. field only ['cols'] => 40, // For textarea fields only. ['rows'] => 5, // For textarea fields only. ['thumb'] => 'url to thumb image', // For filesfile fields only. ['is_invisible'] => {true, false} // Disable the field depending on shop context. ), 'ANOTHER_FIELD' => array( ... ), ), 'submit' => array() ), 'another fieldset' => ... ); |
Basic declaration
Removing all the optional fields, this is how to build a basic HelperOptions element:
Code Block |
---|
$this->fields_options = array(
'general' => array(
'title' => $this->l('Parameters'),
'fields' => array(
'PS_MYMODULE_OPTION1' => array(
'title' => $this->l('Choose one'),
'desc' => $this->l('Choose between Yes and No.'),
'cast' => 'boolval',
'type' => 'bool'
),
'PS_MYMODULE_OPTION2' => array(
'title' => $this->l('Add some text'),
'desc' => $this->l('This is where you can add some text'),
'cast' => 'strval',
'type' => 'text',
'size' => '10'
)
)
)
); |