From e278a819a1d4468cc4462822d288392df3987438 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 16 Sep 2010 02:17:38 +0000 Subject: [PATCH] BUGFIX Passing $name in MoneyField->FieldCurrency() (fixes #5982, thanks andersw) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@110835 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/MoneyField.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/forms/MoneyField.php b/forms/MoneyField.php index cd95be425..18649d2ee 100644 --- a/forms/MoneyField.php +++ b/forms/MoneyField.php @@ -31,7 +31,7 @@ class MoneyField extends FormField { function __construct($name, $title = null, $value = "", $form = null) { // naming with underscores to prevent values from actually being saved somewhere $this->fieldAmount = new NumericField("{$name}[Amount]", _t('MoneyField.FIELDLABELAMOUNT', 'Amount')); - $this->fieldCurrency = $this->FieldCurrency(); + $this->fieldCurrency = $this->FieldCurrency($name); parent::__construct($name, $title, $value, $form); } @@ -47,19 +47,20 @@ class MoneyField extends FormField { } /** + * @param string $name - Name of field * @return FormField */ - protected function FieldCurrency() { + protected function FieldCurrency($name) { $allowedCurrencies = $this->getAllowedCurrencies(); if($allowedCurrencies) { $field = new DropdownField( - "{$this->name}[Currency]", + "{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency'), ArrayLib::is_associative($allowedCurrencies) ? $allowedCurrencies : array_combine($allowedCurrencies,$allowedCurrencies) ); } else { $field = new TextField( - "{$this->name}[Currency]", + "{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency') ); } @@ -136,7 +137,7 @@ class MoneyField extends FormField { // @todo Has to be done twice in case allowed currencies changed since construction $oldVal = $this->fieldCurrency->Value(); - $this->fieldCurrency = $this->FieldCurrency(); + $this->fieldCurrency = $this->FieldCurrency($this->name); $this->fieldCurrency->setValue($oldVal); }