I have a problem with an action in HelperList.
If I click the delete button, I need to delete the record from the database.
I put the function in postProcess, but nothing happens.
If I had the SQL query displayed via echo, that's fine.
Where is the mistake please?
Thank you
public function postProcess() { if (Tools::isSubmit('delete'.$this->name)) { Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'my_module WHERE id = '.Tools::getValue('id')); } }
public function renderList()
{
$sql = new DbQuery();
$sql->select('pa.*');
$sql->from('my_module', 'pa');
$sql->orderBy('pa.id');
$links = Db::getInstance()->ExecuteS($sql);
$fields_list = array(
'id' => array(
'title' => $this->l('id'),
'align' => 'center',
'type' => 'text',
'class' => 'fixed-width-xs',
'search' => true,
'orderby' => true,
),
'id_text' => array(
'title' => $this->l('text'),
'type' => 'text',
),
);
$helper = new HelperList();
$helper->orderBy = 'id';
$helper->orderWay = 'DESC';
$helper->bulk_actions = true;
$helper->shopLinkType = '';
$helper->no_link = true;
$helper->simple_header = false;
$helper->actions = array('delete');
$helper->show_toolbar = true;
$helper->toolbar_btn['new'] = array('href' => AdminController::$currentIndex . '&configure=' . $this->name . '&add' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Add new'));
$helper->module = $this;
$helper->listTotal = count($links);
$helper->_default_pagination = 25;
$helper->toolbar_scroll = true;
$helper->identifier = 'id';
$helper->title = $this->l('custom text');
$helper->table = 'my_module';
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
return $helper->generateList($links, $fields_list);
}