Be defensive with token availability

This commit is contained in:
Daniel Hensby 2015-08-27 17:58:43 +01:00
parent 899eb0b235
commit 8015919932

View File

@ -657,8 +657,10 @@ class Form extends RequestHandler {
$extraFields = new FieldList(); $extraFields = new FieldList();
$token = $this->getSecurityToken(); $token = $this->getSecurityToken();
if ($token) {
$tokenField = $token->updateFieldSet($this->fields); $tokenField = $token->updateFieldSet($this->fields);
if($tokenField) $tokenField->setForm($this); if($tokenField) $tokenField->setForm($this);
}
$this->securityTokenAdded = true; $this->securityTokenAdded = true;
// add the "real" HTTP method if necessary (for PUT, DELETE and HEAD) // add the "real" HTTP method if necessary (for PUT, DELETE and HEAD)