Jump to content

First module: Click to change boolean value in list view


jondm

Recommended Posts

I'm creating my first prestashop module and i have problem when i change the boolean value.

 

If I click over icon of boolean value, it looks like it is changing, but, when finish the boolean value is the same and the other values are deleted.

 

Someone know how can I fix it?

 

 

Thanks!

 

Link to comment
Share on other sites

Sorry, i'll try with images.

 

I create a new bill, and add correctly.

error1.jpg

 

Here we can see the dates added correctly.

 

When I click in the status icon to change (in the red "x" image), i get this:

error2.jpg

 

As you can see, when i click in the button, the data saved disappear and the status continue in the same value.

 

thanks for your help :)

Link to comment
Share on other sites

$this->fields_list = array(
            ...
            'status' => array('title' => $this->l('Status'), 'class' => 'fixed-width-xs', 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => FALSE),
            ...
        );

and the renderList function

public function renderList()
    {
	$this->addRowAction('view');
        $this->addRowAction('edit');
        $this->addRowAction('delete');
		
	$this->simple_header = false;

        return parent::renderList();
    }

thanks :)

Link to comment
Share on other sites

Can't see any issues offhand, had a check in one of my own admin helperlists, is pretty similar

			'comment_status' => array(
				'title' => $this->l('Status'), 
				'type' => 'bool', 
				'width' => '50', 
				'align' => 'center', 
				'active' => 'status', 
				'icon' => array(
					0 => 'disabled.gif', 
					1 => 'enabled.gif', 
				  'default' => 'disabled.gif'
				),
			),

Is what I have on my $this->fields_list

 

Hmm, maybe you need a custom status update method, might be that causing the issue, I also have this in there

public function processStatus()
{
	$db = Db::getInstance();
	if(($id_comment = (int)Tools::getValue('id_comment'))){
		$update = $db->execute('UPDATE `'._DB_PREFIX_.'comments` SET `comment_status` = (1 - `comment_status`) WHERE `id_comment` = '.(int)$id_comment.' LIMIT 1');
	}
	if(isset($update) && $update){
		$this->redirect_after = self::$currentIndex.$this->currentIndex.'&conf=5&token='.$this->token;
		return true;
	} else {
		$this->errors[] = Tools::displayError('An error occurred while updating the status.');
		return false;
	}
}

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...