Search code examples
phpprestashop

How to check if the button was clicked backoffice PrestaShop


I have buttons on .tpl files but on my main page ... .php I can't check if the button is clicked. I can't resolve the problem and I need help

on getContent

if (Tools::isSubmit('submit'.$this->name)) {

      echo 'lol';
}

on displayForm()

// Init Fields form array
    $fields_form = array();
    $fields_form[0]['form'] = array(

        'legend' => array(
            'title' => $this->l('WINMAX TO PRESTASHOP'),
        ),
        'input' => array(
            array(
              'type' => 'checkbox',
                       'label' => $this->l('Escolha as categorias que deseja:'),
                       'hint'=>$this->l('Selecionar depois carregar em Save'),
                       'name' => 'checkBoxi[]',
                       'values' => array(
                           'query' => $data_array,
                           'id' => 'id',
                           'name' => 'name'
            )              
          )
        ),
        'submit' => array(
            'title' => $this->l('Save'),
            'name'=>$this->l('Save'),
            'class' => 'btn btn-default pull-right'
        )
    );

...

    $helper->submit_action = 'submit'.$this->name;
    $helper->toolbar_btn = array(
        'save' =>
        array(
            'desc' => $this->l('Save'),
            'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
            '&token='.Tools::getAdminTokenLite('AdminModules'),
        ),
        'back' => array(
            'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
            'desc' => $this->l('Back to list')
        )
    );
    return $helper->generateForm($fields_form);
  }

I tried to change the name 'submit' to Save but nothing changes.


Solution

  • Try to debug all data which transfers with var_dump(Tools::getAllValues()) in the beginning of getContent() method and you can check out whether your button has that name or not