title: Prestashop HelperForm: switch button
body: <p>I am using Prestashop <code>HelperForm</code> to generate a switch button. The status of the button depends on data generated from database. The problem is that the button is always set to false.</p>
  
  <p>Here is the code :</p>
  
  <pre><code>$fields_form = array(
          'form' =&gt; array(
              'legend' =&gt; array(
                  'title' =&gt; $this-&gt;l('Champs pour feuille de soin'),
                  'icon' =&gt; 'icon-pencil'
              ),
  
              'input' =&gt; array(
                  array(
                      'type' =&gt; 'hidden',
                      'name' =&gt; 'id_product',
                  ),
                  array(
                      'type' =&gt; 'textarea',
                      'label' =&gt; $this-&gt;l('Label'),
                      'name' =&gt; 'contenu1'
                  ),
                  array(
  
                      'type' =&gt; 'hidden',
                      'name' =&gt; 'id_customization_field1',
                  ),
  
                  array(
                      'type' =&gt; 'radio',
                      'label' =&gt; $this-&gt;l('required'),
                      'name' =&gt; 'relab1',
                      'is_bool' =&gt; false,
                      'desc' =&gt; $this-&gt;l('required'),
                      'values' =&gt; array(
                          array(
                              'id' =&gt; 'label1_on',
                              'value' =&gt; 1,
                              'label' =&gt; $this-&gt;l('Enabled')
                          ),
                          array(
                              'id' =&gt; 'label1_off',
                              'value' =&gt; 0,
                              'label' =&gt; $this-&gt;l('Disabled')
                          )
                      )
                  ),
                  array(
                      'type' =&gt; 'textarea',
                      'label' =&gt; $this-&gt;l('Label'),
                      'name' =&gt; 'contenu2'
                  ),
                  array(
  
                      'type' =&gt; 'hidden',
                      'name' =&gt; 'id_customization_field2',
                  ),
                  array(
                      'type' =&gt; 'radio',
                      'label' =&gt; $this-&gt;l('required'),
                      'name' =&gt; 'relab2',
                      'is_bool' =&gt; false,
                      'desc' =&gt; $this-&gt;l('required'),
                      'values' =&gt; array(
                          array(
                              'id' =&gt; 'active_on',
                              'label' =&gt; $this-&gt;l('Enabled')
                          ),
                          array(
                              'id' =&gt; 'active_off',
                              'label' =&gt; $this-&gt;l('Disabled')
                          )
                      )
                  ),
  
  
                  array(
                      'type' =&gt; 'textarea',
                      'label' =&gt; $this-&gt;l('Label'),
                      'name' =&gt; 'contenu3'
                  ),
                  array(
  
                      'type' =&gt; 'hidden',
                      'name' =&gt; 'id_customization_field3',
                  ),
  
                  array(
                      'type' =&gt; 'switch',
                      'label' =&gt; $this-&gt;l('required'),
                      'name' =&gt; 'relab3',
                      'is_bool' =&gt; true,
                      'desc' =&gt; $this-&gt;l('required'),
                      'values' =&gt; array(
                          array(
                              'id' =&gt; 'label3_on',
                              'value' =&gt; 1,
                              'label' =&gt; $this-&gt;l('Enabled')
                          ),
                          array(
                              'id' =&gt; 'label3_off',
                              'value' =&gt; 0,
                              'label' =&gt; $this-&gt;l('Disabled')
                          )
                      )
                  ),
  
  
                  array(
                      'type' =&gt; 'textarea',
                      'label' =&gt; $this-&gt;l('Label'),
                      'name' =&gt; 'contenu4'
                  ),
                  array(
  
                      'type' =&gt; 'hidden',
                      'name' =&gt; 'id_customization_field4',
                  ),
  
                  array(
                      'type' =&gt; 'checkbox',
                      'label' =&gt; $this-&gt;l('Required'),
                      'name' =&gt; 'label4',
                      'class' =&gt; 't',
                      'multiple' =&gt; true,
                      'values' =&gt; array(
                          'query' =&gt; array($label3),
                          'id' =&gt; 'label4',
                          'name' =&gt; 'label4',
                          'expand' =&gt; array(
                              'default' =&gt; 'show',
                              'show' =&gt; array('text' =&gt; $this-&gt;l('show'), 'icon' =&gt; 'plus-sign-alt'),
                              'hide' =&gt; array('text' =&gt; $this-&gt;l('hide'), 'icon' =&gt; 'minus-sign-alt')
                          ),
                      )
                  ),
  
  
              ),
              'submit' =&gt; array(
                  'title' =&gt; $this-&gt;l('Save'),
                  'name' =&gt; $this-&gt;l('submitAddproduct'),
              )
          ),
      );
  
      $helper = new HelperForm();
      $helper-&gt;show_toolbar = false;
      $helper-&gt;table = $this-&gt;table;
      $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
      $helper-&gt;default_form_language = $lang-&gt;id;
      $helper-&gt;allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
      $helper-&gt;identifier = $this-&gt;identifier;
      $helper-&gt;submit_action = 'submitUpdate';
      $helper-&gt;currentIndex = $this-&gt;context-&gt;link-&gt;getAdminLink('AdminModules', false) . '&amp;configure=' . $this-&gt;name . '&amp;tab_module=' . $this-&gt;tab . '&amp;module_name=' . $this-&gt;name;
      $helper-&gt;token = Tools::getAdminTokenLite('AdminModules');
      $helper-&gt;tpl_vars = array(
          $helper-&gt;fields_value['id_product'] = Tools::getValue('id_product'),
          'relab4' =&gt; 1,
  
          'languages' =&gt; $this-&gt;context-&gt;controller-&gt;getLanguages(),
          'id_language' =&gt; $this-&gt;context-&gt;language-&gt;id
      );
  
      $helper-&gt;fields_value['contenu1'] = $contenu1;
      $helper-&gt;fields_value['contenu2'] = $contenu2;
      $helper-&gt;fields_value['contenu3'] = $contenu3;
      $helper-&gt;fields_value['contenu4'] = $contenu4;
      $helper-&gt;fields_value['relab1'] = (int)$relab1;
      $helper-&gt;fields_value['relab2'] = (int)$relab2;
      $helper-&gt;fields_value['relab3'] = (int)$relab3;
      $helper-&gt;fields_value['relab4'] = (int)$relab4;
      $helper-&gt;fields_value['id_customization_field1'] = $id_customization_field1;
      $helper-&gt;fields_value['id_customization_field2'] = $id_customization_field2;
      $helper-&gt;fields_value['id_customization_field3'] = $id_customization_field3;
      $helper-&gt;fields_value['id_customization_field4'] = $id_customization_field4;
  
  
      return $helper-&gt;generateForm(array($fields_form));
  </code></pre>