mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Removed clone behaviour from Form::Fields()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49173 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
27f29acdb9
commit
8f4ed9d16b
@ -35,6 +35,11 @@ class Form extends ViewableData {
|
||||
*/
|
||||
protected $hasDefaultAction = true;
|
||||
|
||||
/**
|
||||
* Variable set to true once the SecurityID hidden field has been added.
|
||||
*/
|
||||
protected $securityTokenAdded = false;
|
||||
|
||||
/**
|
||||
* Accessed by Form.ss; modified by formHtmlContent.
|
||||
* A performance enhancement over the generate-the-form-tag-and-then-remove-it code that was there previously
|
||||
@ -176,7 +181,7 @@ class Form extends ViewableData {
|
||||
* @return FieldSet The form fields
|
||||
*/
|
||||
function Fields() {
|
||||
if($this->securityTokenEnabled()) {
|
||||
if(!$this->securityTokenAdded && $this->securityTokenEnabled()) {
|
||||
if(Session::get('SecurityID')) {
|
||||
$securityID = Session::get('SecurityID');
|
||||
} else {
|
||||
@ -184,13 +189,11 @@ class Form extends ViewableData {
|
||||
Session::set('SecurityID', $securityID);
|
||||
}
|
||||
|
||||
$fieldsClone = clone $this->fields;
|
||||
$fieldsClone->push(new HiddenField('SecurityID', '', $securityID));
|
||||
|
||||
return $fieldsClone;
|
||||
} else {
|
||||
return $this->fields;
|
||||
$this->fields->push(new HiddenField('SecurityID', '', $securityID));
|
||||
$this->securityTokenAdded = true;
|
||||
}
|
||||
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user