SRUTHI R BABU Posted August 2, 2022 Share Posted August 2, 2022 (edited) 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 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 August 2, 2022 by SRUTHI R BABU (see edit history) Link to comment Share on other sites More sharing options...
knacky Posted August 2, 2022 Share Posted August 2, 2022 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>'; } } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now