我正在为前台创建一个Recaptcha模块,所有代码都可以,但是错误消息将发送到错误的位置。
我正在使用Prestashop 1.7.6.1,错误消息正在前台打印,并且我需要错误消息才能在表格框中打印。
我将这样设置错误消息: modules / recaptcha / recaptcha.php
public function hookactionRecaptchaaccountValidation()
{
if (!$this->isValidateRecaptcha()) { // Logic to validate recaptcha
// Set my error message
$context->controller->errors[] = $this->l('It was not possible to validate the reCaptcha.');
}
}
我正在重写AuthController来执行我的自定义钩子,这将使Recaptcha验证逻辑生效,这很好,如果需要的话,我也放置了这段代码。
class AuthController extends AuthControllerCore
{
public function initContent()
{
if(Tools::isSubmit('submitLogin')){
// Execute my custom hook
Hook::exec('actionRecaptchaaccountValidation');
if(sizeof($this->context->controller->errors)){ // Verify if has error message
$login_form = $this->makeLoginForm()->fillWith(
Tools::getallValues()
);
$this->context->smarty->assign([
'login_form' => $login_form->getProxy(),]);
$this->setTemplate('customer/authentication');
FrontController::initContent();
return;
}
}
parent::initContent();
}
}
...因此,如何将错误消息放入此示例的表单框中?
请检查这张图片,在其中准确显示我的需求。 https://i.imgur.com/Syzrf2C.png