唯一的方法似乎是覆盖sfForm::addCSRFProtection().
在/lib/form/BaseForm.class.php你可以添加这段代码:
class BaseForm extends sfFormSymfony
{
public function addCSRFProtection($secret = null)
{
parent::addCSRFProtection($secret);
if (array_key_exists(self::$CSRFFieldName, $this->getValidatorSchema())) {
$this->getValidator(self::$CSRFFieldName)->setMessage('csrf_attack', 'This session has expired. Please return to the home page and try again.');
}
}
}
Run Code Online (Sandbox Code Playgroud)
在调用父方法之后,您将检索与CSRF字段关联的验证程序并更改代码的消息csrf_attack.
编辑:您还需要检查验证器是否存在.某些表单可能会禁用其CSRF保护!
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
8561 次 |
| 最近记录: |