I'm in charge of creating a small payment module. The configuration has to be managed with a simple CRUD, and I use the HelperList class to display a table with the records stored in the database. One of the tables database structure is similar to this
'CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'MODULE_ITEM
(
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`active` VARCHAR(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;'
So, the list_fields value is like this
array(
'id' => array(
title' => $this->l('Id'),
//'width' => 140,
'type' => 'text',
'align' => 'center'
),
'name' => array(
'title' => $this->l('Name'),
//'width' => 140,
'type' => 'text',
'align' => 'center'
),
'active' => array(
'title' => $this->l('Status'),
//'width' => 140,
'active' => 'statusItem',
'type' => 'boolean',
'align' => 'center',
'ajax'=> true
)
);
As I intend to enable or disable the item via a button I use the 'active' and 'ajax' options for this specific field, and when rendered in the module configuration page the link generated for the column in question is something like: index.php?controller=AdminModules&configure=Example&item_id=4&statusItem&action=statusItem&ajax=1&(...)
. Please notice that statusItem is the name of the action.
On the other hand, I wrote this function in the module main file, which should change the item status.
public function ajaxProcessStatusItem()
{
$id=(int)Tools::getValue('item_id');
$value=(int) Db::getInstance()->executeS($this->createSelectQuery('module_item','item_id',$id))[active];
Db::getInstance()->update('module_item', array('active' => !$value), 'item_id='.$id);
die();
}
I've been using this article of the official documentation to create the list, but no matter what name I use ('ajaxProcess', 'ajaxProcessSatusItem', 'statusItem', and every caps variation I could think of) all I get is a blank page in response, and no change in the status. I had a look at the source code and there is no comment in the HelperList class regarding how the function should be called.
Any help will be appreciated.