Jump to content

HelperList callback not work


Recommended Posts

i have one module,on config page i render some helperlist.the code is this:

protected function renderList()
    {
        $query = new DbQuery();
        $query->select('*');
        $query->from('carrier');
        $query->where('active=1 AND deleted=0');
        $rates = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query->build());

        $fields_list = array(
            'id_carrier' => array(
                'title' => $this->l('ID'),
                'align' => 'center',
                'class' => 'fixed-width-xs'
            ),
            'name' => array(
                'title' => $this->l('Carrier')
            ),
            'test' => array(
                'title' => $this->l('test'),
                'callback' => 'getSetCarrier',
            ),
            'active' => array(
                'title' => $this->l('Active'),
            )
        );
        $helper = new HelperList();
        $helper->shopLinkType = 'shop';
        $helper->simple_header = true;
        $helper->actions = array("edit");
        $helper->show_toolbar = false;
        $helper->module = $this;
        $helper->listTotal = count($rates);
        $helper->identifier = 'id_carrier';
        $helper->title = '';
        $helper->table = $this->name;
        $helper->token = Tools::getAdminTokenLite('AdminModules');
        $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;

        return $helper->generateList($rates, $fields_list);
    }

    public function getSetCarrier()
    {
        return 'aaa';
    }

in the renderList function,i set the callback is getSetCarrier. And in getSetCarrier function,i return string 'aaa'.

but,the carrier list is not echo 'aaa'

5a43402c10b5f_TIM20171227143924.thumb.png.964dbe57f82432e721eeae4470343753.png

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Try to add 'test' in your select query:

$this->fields_list = array (
                'test' => array(
                        'title' => $this->l('test'),
                        'callback' => 'getSetCarrier',
                ));

$this->_select .= '  \'\' as test  ';

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...