如何解决Prestashop:从 B.O 中删除姓氏字段规则验证
我正在尝试删除客户姓氏字段的规则验证..
通过编辑 Classes/Customer.PHP 文件,我已经成功地在客户注册的首页上做到了:
'lastname' =>array('type' => self::TYPE_STRING,'validate' => 'isCustomerName','required' => true,'size' => 32),
到:
'lastname' =>array('type' => self::TYPE_STRING,'validate' => 'isAnything',
我只是在验证中使用了 isAnything。
但这在后台中不起作用,因此我无法从 BO 编辑客户。
找不到要准确更改的文件。
我使用的是 Prestashop V1.7.6.8。 需要帮助请。谢谢
解决方法
您必须在两个文件中修改两个方法。
src/Core/ConstraintValidator/CustomerNameValidator.php,方法 isNameValid
private function isNameValid($name)
{
return true; // Here true or your own validation.
// Down the original code.
$pattern = $this->characterCleaner->cleanNonUnicodeSupport(self::PATTERN_NAME);
return (bool) preg_match($pattern,$name);
}
src/Core/Domain/Customer/ValueObject/LastName.php,方法 assertLastNameIsValid
private function assertLastNameIsValid($lastName)
{
return true; // Here true or your own validation.
// Down the original code.
$matchesLastNamePattern = preg_match('/^[^0-9!<>,;?=+()@#"°{}_$%:¤|]*$/u',stripslashes($lastName));
if (!$matchesLastNamePattern) {
throw new CustomerConstraintException(sprintf('Customer last name %s is invalid',var_export($lastName,true)),CustomerConstraintException::INVALID_LAST_NAME);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。