I want a type switch to change value in css class but type switch does not support custom values then 1 and 0? how to do it?
'input' => array(
'type' => 'switch',
'label' => $this->l('backgrounds'),
'name' => 'test',
'options' => array(
'query' => $test,
'id' => 'id_option',
'name' => 'name'
)
)
),
$test = array(
array(
'id_option' => '#header {background: #ffffff;}',
'name' => $this->l('white bg')
),
array(
'id_option' => '#header {background: #333333;}',
'name' => $this->l('dark bg')
),
);
For type 'switch' you have to use 'values' instead of 'options'.
This is example from default PrestaShop module :
$input = array(
'type' => 'switch',
'label' => $this->trans('Newsletter', array(), 'Admin.Orderscustomers.Feature'),
'name' => 'newsletter',
'required' => false,
'class' => 't',
'is_bool' => true,
'value' => $newsletter,
'values' => array(
array(
'id' => 'newsletter_on',
'value' => 1,
'label' => $this->trans('Enabled', array(), 'Admin.Global'),
),
array(
'id' => 'newsletter_off',
'value' => 0,
'label' => $this->trans('Disabled', array(), 'Admin.Global'),
)
),
'hint' => $this->trans('This customer will receive your newsletter via email.', array(), 'Admin.Orderscustomers.Help'),
);
I think switch is only supporting "On"/"Off" and "Yes/No" values - you could try to change the following logic in form.tpl but it seems to be easier to use another type instead
<label {if $value.value == 1} for="{$input.name}_on"{else} for="{$input.name}_off"{/if}>
{if $value.value == 1}
{l s='Yes' d='Admin.Global'}
{else}
{l s='No' d='Admin.Global'}
{/if}
</label>