I can only tell you 100% for sure that this works for the actionProductUpdate hook, but I imagine it's valid everywhere. Here's a quick snippet to show you the general idea....
public function hookActionProductUpdate($params) { if (!Validate::isInt (Tools::getValue('pwr_start'))) { $this->context->controller->errors[] = "Ya screwed up!"; } }
There are 3 main things you want to take note of:
- Use the Validate class to validate your input data
- Use Tools::getValue instead of directly pulling things from $_GET / $_POST. This does some light purification of the input data.
- If you want to stop the submit of the form, add the error to the controller's error list. Unfortunately, this is only reported at the top of the form.
No comments:
Post a Comment