Permalink
Browse files

BUGFIX Passing $name in MoneyField->FieldCurrency() (fixes #5982, tha…

…nks andersw) (from r110835)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112848 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 61bb2fe commit 9d4d7301a276f22ad80d2b5e3ba4a0d9cb70a6e6 @sminnee sminnee committed Oct 19, 2010
Showing with 6 additions and 5 deletions.
  1. +6 −5 forms/MoneyField.php
View
11 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 @@ function Field() {
}
/**
+ * @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 @@ function setAllowedCurrencies($arr) {
// @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);
}

0 comments on commit 9d4d730

Please sign in to comment.