/** * Enables CSRF protection for this form. */ public function enableCsrfProtection($csrfFieldName = null, $csrfSecret = null) { if (!$this->isCsrfProtected()) { if (null === $csrfFieldName) { $csrfFieldName = FormConfiguration::getDefaultCsrfFieldName(); } if (null === $csrfSecret) { $csrfSecret = md5(__FILE__ . php_uname()); } $field = new HiddenField($csrfFieldName, array('property_path' => null)); $field->setData($this->generateCsrfToken($csrfSecret)); $this->add($field); $this->csrfFieldName = $csrfFieldName; $this->csrfSecret = $csrfSecret; } }