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:
Sam Minnee 2008-02-07 02:58:23 +00:00
parent 27f29acdb9
commit 8f4ed9d16b

View File

@ -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;
}
/**