NishantVadgama Posted August 28, 2014 Share Posted August 28, 2014 (edited) hello I have successfully created new tab in admin with hookDisplayAdminProductsExtra() but when save data with hookActionProductUpdate() save as well but I want to validate before save data and give return back error if exits but I cant return error. It will directly save data.. if I post wrong data then it will give sql error but not mine. I have validate as follows. public function hookActionProductUpdate() { if (Tools::getValue('id_test')) { if(!Validate::isInt(Tools::getValue('id_test'))) { $this->context->controller->_errors[] = Tools::displayError('Please enter valid data.'); } if(!count($this->context->controller->_errors)) { someObj = newObj(); someObj.saveData(Tools::getValue('id_test')); } } } Edited August 28, 2014 by NishantVadgama (see edit history) Link to comment Share on other sites More sharing options...
PhpMadman Posted August 28, 2014 Share Posted August 28, 2014 try without the [] on this line if(!$this->context->controller->_errors[]) Link to comment Share on other sites More sharing options...
NishantVadgama Posted August 28, 2014 Author Share Posted August 28, 2014 try without the [] on this line if(!$this->context->controller->_errors[]) thanks for the help but still not return error that I want I have change as follows if(!count($this->context->controller->_errors)) { someObj = newObj(); someObj.saveData(Tools::getValue('id_test')); } Link to comment Share on other sites More sharing options...
PhpMadman Posted August 28, 2014 Share Posted August 28, 2014 try adding echo 'got value' and so on to check that all the if's are executed. Just so we can confirm that. and to a print_r of _errors before you check the count on it. Link to comment Share on other sites More sharing options...
NishantVadgama Posted August 28, 2014 Author Share Posted August 28, 2014 I have found problem solved the problem is only in "_errors" inspite of that just have to write "errors". thank You 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