Jump to content

HelperList callback problem


Recommended Posts

I make a module and i need make a custom button on my helper  list.

My code:

protected function initList()
	{
	    // Fix table drag bug.
        Media::addJsDef(array(
            'currentIndex' => AdminController::$currentIndex.'&configure='.$this->name,
        ));

		$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
			),
			'position' => array(
				'title' => $this->getTranslator()->trans('Position', array(), 'Modules.Recpsbeta.Admin'),
				'class' => 'fixed-width-xxl',
				'position' => 'position',
                'search' => false,
                'orderby' => false
			),
            'active' => array(
    			'title' => $this->getTranslator()->trans('Status', array(), 'Modules.Recpsbeta.Admin'), 
                'class' => 'fixed-width-xxl',
                'active' => 'status',
    			'align' => 'center',
                'type' => 'bool',
                'search' => false,
                'orderby' => false
            ),
            'id_temp' => array(
                'title' => $this->l('id_temp'),
                'align' => 'text-center',
                'callback' => 'printAll',
                'orderby' => false,
                'search' => false,
                'class' => 'button',
                //'remove_onclick' => true
            ),
		);

		if (Shop::isFeatureActive())
			$this->fields_list['id_shop'] = array(
                'title' => $this->getTranslator()->trans('ID Shop', array(), 'Modules.Recpsbeta.Admin'), 
                'align' => 'center', 
                'class' => 'fixed-width-sm',
                'type' => 'int',
                'search' => false,
                'orderby' => false
            );

		$helper = new HelperList();
        $helper->shopLinkType = '';
		$helper->simple_header = false;
		$helper->identifier = 'id_rec_ps_beta';
		$helper->actions = array('edit', 'delete','pdf');
		$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;
	}

And i call the function of the button:

    /*---------------------------printAll Function----------------------------*/
    public function printAll($id)
{

        return 'loool';
}

But i see nothing:

e5e236f1950c5e927ee17cf82cb840cc.thumb.png.a8da7e0a46eddf3b6865ce8f7e74b197.png

 

Someone help me please? I have not found a solution for days.

Thx.

Link to comment
Share on other sites

Hi,

 

Try to set inside $this->_select you property.

Exemple, with my code:

public function __construct()
{
	$this->fields_list = array(
		'categorylink' => array(
            'title'    => $this->l('Category link'),
            'orderby'  => false,
            'callback' => 'getProtectedCategoryLink'
		),
	);
}

public function renderList()
{
	$this->_select = '0 as categorylink';
}

public function getProtectedCategoryLink($value, $form)
{
ppp($value);
ddd($form);
}

 

Edited by iradorn (see edit history)
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...