I make a module and i need make a custom button on my helper list for get a value and open a file, but my callback on HelperList
doesn't work...
My code:
protected function initList()
{
$this->_select = 'a.id_rec_ps_beta AS id_lol';
$this->fields_list = array(
'name' => array(
'title' => $this->getTranslator()->trans('Category name', array(), 'Modules.Recpsbeta.Admin'),
'class' => 'fixed-width-xxl',
'type' => 'text',
'search' => false,
'orderby' => false
),
.....
'id_lol' => array(
'title' => 'LOL',
'align' => 'text-center',
'callback' => 'giveMyCallBack',
'orderby' => false,
'search' => false,
'remove_onclick' => true
)
);
$helper = new HelperList();
$helper->shopLinkType = '';
$helper->simple_header = false;
$helper->identifier = 'id_rec_ps_beta';
//$helper->definition = $helper->identifier;
$helper->actions = array('edit', '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->getTranslator()->trans('Add new', array(), 'Modules.Recpsbeta.Admin')
);
$helper->toolbar_btn['edit'] = array(
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&setting'.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'),
'desc' => $this->getTranslator()->trans('Setting', array(), 'Modules.Recpsbeta.Admin'),
);
$helper->title = $this->displayName;
$helper->table = $this->name;
$helper->orderBy = 'position';
$helper->orderWay = 'ASC';
$helper->position_identifier = 'id_rec_ps_beta';
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
return $helper;
}
After i call my function:
public function giveMyCallBack ($id_rec_ps_beta)
{
return 'lol';
}
But my list like:
And before my page report a error: "Warning line 335 file C:\wamp64\www\ps2\classes\helper\HelperList.php [ 2 ] call_user_func_array() expects parameter 1 to be a valid callback, class 'AdminModulesController' does not have a method 'giveMyCallBack'"
Someone help me please? I have not found a solution for days.
Thx.
PrestaShop: 1.7.3.3 Apache: 2.4.27 (Win64) PHP: 5.6.31 MySQL: 5.7.19
At the moment I only found this solution:
$this->fields_list = array(
'id_rec_ps_beta' => array(
'title' => $this->trans('Title', array(), 'Admin.Global'),
'search' => false,
'align' => 'text-center',
'class' => 'fixed-width-xs',
'prefix' => '<span class="btn-group-action"><span class="btn-group"><a class="btn btn-default" style="padding: 0px 0px;border-color: #efefef;" href="'.AdminController::$currentIndex.'&configure='.$this->name.'&gen'.$this->name.'&btngenrecpsbeta&id_rec_ps_beta=',
'suffix' => '&print=1&token='.Tools::getAdminTokenLite('AdminModules').'"><img src="'.__PS_BASE_URI__.'modules/recpsbeta/views/img/sync.png" style="width: 35px;"></a></span></span>'
),
);
I hope it can be useful to some.