Mantovani Maurizio Posted June 9, 2016 Share Posted June 9, 2016 (edited) I follow this tutorial But when the user press the delete button the page only reload. I show all result of my table, but i cant delete any result. My table is: CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'tablename` ( `id_tb` int(10) NOT NULL AUTO_INCREMENT, `val1` varchar(128) NOT NULL, `val2` varchar(128) NOT NULL, `val3` varchar(128) NOT NULL, `val4` int(1) NOT NULL, `val5` varchar(128) NOT NULL, `val6` varchar(128) NOT NULL, PRIMARY KEY (`id`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; and my code is: public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('PRESTA_MODULE_BETA')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('PRESTA_MODULE_BETA', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->initList(); } public function initList() { // Select all available extra info tabs $sql = 'SELECT * FROM '. _DB_PREFIX_ .'tablename'; if ($result = Db::getInstance()->ExecuteS($sql)) { $this->fields_list = array( 'id_tb' => array( 'title' => 'ID', 'width' => 'auto', 'search' => 'true', 'type' => 'text', 'tmpTableFilter' => 'true', 'havingFilter' => 'true', 'filter_type' => 'int' ), 'val1' => array( 'title' => 'titleval1', 'width' => 'auto', 'type' => 'text' ), 'val2' => array( 'title' => 'titleval2', 'width' => 'auto', 'type' => 'text' ), 'val3' => array( 'title' => 'titleval3', 'width' => 'auto', 'type' => 'text' ), 'val4' => array( 'title' => $this->l('titleval4'), 'width' => 'auto', 'type' => 'text' ), 'val5' => array( 'title' => 'titleval5', 'width' => 'auto', 'type' => 'text' ), 'val6' => array( 'title' => 'titleval6', 'width' => 'auto', 'type' => 'bool', 'ajax'=> true, 'icon' => array( 0 => 'disabled.gif', 1 => 'enabled.gif', 'default' => 'disabled.gif' ), ) ); $helper = new HelperList(); $helper->shopLinkType = ''; $helper->identifier = 'id_tb'; $helper->actions = array('edit', 'delete'); $helper->show_toolbar = 'false'; $helper->title = $this->displayName; $helper->table = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->simple_header = 'false'; $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; return $helper->generateList($result, $this->fields_list); } return false; } Some solution? Thanks, look your news, I wold be infinitely grateful. Bye. Edited June 9, 2016 by Mantovani Maurizio (see edit history) Link to comment Share on other sites More sharing options...
Stéphane Dessaint Posted August 19, 2016 Share Posted August 19, 2016 (edited) public function getContent() { $output = null; if ( Tools::isSubmit('delete'.$this->name) ) { $this->deleteLine(); } if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('PRESTA_MODULE_BETA')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('PRESTA_MODULE_BETA', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->initList(); } When you delete line, he will call function ''deleteLine()" with param in $_REQUEST Edited August 19, 2016 by Stéphane Dessaint (see edit history) Link to comment Share on other sites More sharing options...
Mantovani Maurizio Posted August 26, 2016 Author Share Posted August 26, 2016 Thank you very much, the function is called. But rightly not having created gives me this: Call to undefined method recpsbeta :: deleteLine () Solutions? Link to comment Share on other sites More sharing options...
Mantovani Maurizio Posted August 26, 2016 Author Share Posted August 26, 2016 Ok have make my function for delet: public function deleteLine() { Db::getInstance()->delete('tablename', 'id = 59'); } It work... But.. how get a id variable? ex: public function deleteLine() { Db::getInstance()->delete('tablename', 'id = $idvariable'); } Link to comment Share on other sites More sharing options...
Mantovani Maurizio Posted August 27, 2016 Author Share Posted August 27, 2016 Ok.. delete opzion work: public function deleteLine($id_num) { Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute("DELETE FROM "._DB_PREFIX_."namemoduletable WHERE id_num='$id_num'"); } and: public function getContent() { $output = null; if ( Tools::isSubmit('delete'.$this->name) ) { $this->deleteLine(Tools::getValue('id_num')); } if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('PRESTA_MODULE_BETA')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('PRESTA_MODULE_BETA', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->initList(); } So.. i want to make other opzion.. thx for the support! Link to comment Share on other sites More sharing options...
SilviaPimenta Posted February 22, 2017 Share Posted February 22, 2017 Hello,I'm looking for a solution to a module I'm doing for prestashop version 1.6.I want it in my renderList listing in this code:$ Helper-> actions = array ('edit', 'send');I'll send the shipping but I still can not.Someone can help me?Thanks.I apologize for my English. Sílvia Pimenta. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now