Php 如何将错误消息放入Prestashop 1.7内部表单框中?

Php 如何将错误消息放入Prestashop 1.7内部表单框中?,php,prestashop,prestashop-1.7,prestashop-modules,Php,Prestashop,Prestashop 1.7,Prestashop Modules,我正在为前台办公室创建一个recaptcha模块,所有代码都正常,但错误消息发错了地方 我正在使用Prestashop 1.7.6.1,错误消息正在前台打印,我需要在表单框内打印错误消息 我将错误消息设置为: modules/recaptcha/recaptcha.php 公共函数hookActionRecaptchaAccountValidation() { 如果(!$this->isValidateRecaptcha()){//验证recaptcha的逻辑 //设置我的错误消息 $conte

我正在为前台办公室创建一个recaptcha模块,所有代码都正常,但错误消息发错了地方

我正在使用Prestashop 1.7.6.1,错误消息正在前台打印,我需要在表单框内打印错误消息

我将错误消息设置为: modules/recaptcha/recaptcha.php

公共函数hookActionRecaptchaAccountValidation()
{
如果(!$this->isValidateRecaptcha()){//验证recaptcha的逻辑
//设置我的错误消息
$context->controller->errors[]=$this->l('无法验证reCaptcha');
}
}
我正在重写AuthController来执行我的自定义钩子,它将生成recaptcha验证逻辑,这里是确定的,我也把这段代码放在这里,以防您需要

类AuthController扩展AuthControllerCore { 公共函数initContent() { if(工具::isSubmit('submitLogin')){ //执行我的自定义钩子 Hook::exec('actionRecaptchaAccountValidation'); if(sizeof($this->context->controller->errors)){//验证是否有错误消息 $login\u form=$this->makeLoginForm()->fillWith( 工具::getAllValues() ); $this->context->smarty->assign([ 'login\u form'=>$login\u form->getProxy(), ]); $this->setTemplate('customer/authentication'); FrontController::initContent(); 返回; } } 父::initContent(); } } …那么,如何将错误消息放入表单框中,如本例所示

请检查这张图片,在那里我显示了我需要的东西。

我认为您应该更好地查看<代码> CubjLogLogVelue/Cux>类,并考虑重写它。
submit
方法可能正是您想要的。只需再添加一个验证并使用
$this->errors['][]
construction

定义错误,谢谢您的回复,所以我看到了这个类,所以我认为如果这样做是最好的方法,我的意思是,重写一个类只是为了在CustomerLoginForm->errors中插入一条错误消息。。。我还想了另一件事,我想使用$login\u form->errors在重写类AuthController中插入此错误消息,但问题是CustomerLoginForm->errors is private…=/您知道覆盖CustomerLoginForm是一种好的做法,还是有其他更简单、更实用的方法?2天前,我发现一篇文章是这样做的:$this->context->controller->errors['hooks\u fieldname'][='Error message!';但我试过了,对我不起作用。。。我现在搜索了这篇文章,但找不到。如果我再次发现,我会在这里发布。我发现另一篇文章对我上面所说的进行了评论,但我不确定这是否是针对后台的,文章示例是message to a field。。。