Shop association in HelperForm


  • Global Moderator

    In my helperForm I want to use the inbuilt shop selector. The select tree shows up, but I can’t manage to set up the tpl_vars correctly. Strangely it doesn’t matter what I put under ‘name’ (blabla). The checkboxes always have the name “checkBoxShopAsso_configuration”.

    if (Shop::isFeatureActive()) {
          $inputs[] = array(
              'type' => 'shop',
              'label' => $this->l('Shop association:'),
              'name' => 'blabla',
          );
      }
    
      $fields_form = array(
          'form' => array(
              'legend' => array(
                  'title' => ('Add Link'),
                  'icon' => 'icon-cogs'
              ),
              'input' => $inputs,
              'submit' => array(
                  'title' => ('Update'),
                  'class' => 'btn btn-default pull-right'
              )
          )
      );
    
      $helper = new HelperForm();
      $helper->submit_action = 'saveLink';
      $helper->default_form_language = $this->context->language->id;
      $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name .'&module_name=' . $this->name;
      $helper->token = Tools::getAdminTokenLite('AdminModules');
    
      $vars['blabla'][3] = 0;
    
      $helper->tpl_vars = array(
          'fields_value' => $vars,
          'languages' => $this->context->controller->getLanguages(),
          'id_language' => $this->context->language->id,
      );
    

    How do I need to set up tpl_vars, so that only the shops with an entry are selected? Let’s say I have 3 shops and only in the first two shops is an entry. I thought, I have to do like this:

    $vars['blabla'][1] = 1;
    $vars['blabla'][2] = 1;
    $vars['blabla'][3] = 0;
    

    That’s the way I do for lang fields, but this is not working. It selects always all 3 shops.

    Thanks for your help! If something is unclear, please tell me where you need better explanation.


  • Global Moderator

    Could find a solution. This does the trick:

    $helper->table = 'genzo_link';
    $helper->id = $id_genzo_link;
    $helper->identifier = 'id_genzo_link';
    

Log in to reply
 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.