基础sfForm构造函数配置是否启用以及CSRFSecret是什么。
class sfForm implements ArrayAccess, Iterator, Countable
{
public function __construct($defaults = array(), $options = array(), $CSRFSecret = null)
{
$this->setDefaults($defaults);
$this->options = $options;
$this->localCSRFSecret = $CSRFSecret;
$this->validatorSchema = new sfValidatorSchema();
$this->widgetSchema = new sfWidgetFormSchema();
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setup();
$this->configure();
$this->addCSRFProtection($this->localCSRFSecret);
$this->resetFormFields();
}
}
在这种情况下,如果通过disableLocalCSRFProtection()禁用本地CSRF保护不起作用,您可以尝试用“假” CSRFSecret”创建表单实例
例:
$myForm = new myForm(array(), array(), false);
编辑:(以上建议没有为海报工作)
您可以试试,只是在应用程序的settings.yml中注释“csrf_secret”配置。在评论此行后,不要忘记清除symfony的缓存。要验证全局禁用CSRF保护,您可以按如下方式检查“sf_csrf_secret”配置的值;
var_dump(sfConfig::get('sf_csrf_secret'))
这应该给你一个布尔值false,这意味着在契约中所有的CSRF保护被禁用。
你在哪儿做'$ this-> disableLocalCSRFProtection();'调用?在'YourForm :: configure()'中? – 2012-02-29 21:26:33
是的,我在表单配置中打了电话。 – Patrick 2012-02-29 21:46:22
“_it是一个自定义窗体,并且正在调用父配置,它正在注入csrf protection_”您是否有可能使用'disableLocalCSRFProtection()'在父窗体中禁用csrf保护? – melekes 2012-03-01 15:36:23