Jump to content

Prestashop renderlist - row edit action button


Recommended Posts

I need to disable edit button based on a my module's renderlist from an admin controller I had created.

Eg: if the value has a date >= today edit button should be working it should be disabled.

I understand that I could just redirect the edit link to listing page for a date expired case but if it's possible to disable the edit button it would be better

1846124254_Screenshot-2022-08-02T125207_964.png.ccb9735811e486e04a901c227e4f16ae.png Here's the screenshot of what I am trying to do. The cross mark means need to be disabled. As you can see the field right before actions column is also done according to the said condition

Edited by SRUTHI R BABU (see edit history)
Link to comment
Share on other sites

It makes the most sense to use custom button actions.

public function __construct()
{
...
...
	$this->addRowAction('customEdit');
...
...
}

 

public function displaycustomEditLink($token, $id, $name)
{
	$add_disable = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'my_table WHERE id = '.$id);

	if ($add_disable['my_column'] == '1'){
		$css_disable = '';
		$href = $this->context->link->getAdminLink('MyController').'&id='.$id.'&edit';
		return '<a value="'.$id.'" id="my_custom_edit_button" class="btn btn-default" href="'.$href.'" '. $css_disable . '>'.$this->l('Edit').'</a>';
	} else {
		$css_disable = 'style="pointer-events: none;cursor: default;text-decoration: none;color: black;"';
		$href = '';
		return '<a value="'.$id.'" id="my_custom_edit_button" class="btn btn-default" href="'.$href.'" '. $css_disable . '>'.$this->l('Edit').'</a>';
	}
        
}

 

  • Like 1
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...