From 611d571b65e632597cb2ed9756f56c2838bf8b29 Mon Sep 17 00:00:00 2001 From: Joe Harvey Date: Fri, 10 Jan 2014 15:35:45 +0000 Subject: [PATCH 1/2] BUG corrects MoneyField::setReadonly() method in order to return ReadonlyField instances of its child fields Issue #2766 - This causes our cloned MoneyField to actually contain two ReadonlyFields for currency and amount. --- forms/MoneyField.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forms/MoneyField.php b/forms/MoneyField.php index 129a1b25c..703fbfcf1 100644 --- a/forms/MoneyField.php +++ b/forms/MoneyField.php @@ -131,8 +131,8 @@ class MoneyField extends FormField { public function setReadonly($bool) { parent::setReadonly($bool); - $this->fieldAmount->setReadonly($bool); - $this->fieldCurrency->setReadonly($bool); + $this->fieldAmount = $this->fieldAmount->performReadonlyTransformation(); + $this->fieldCurrency = $this->fieldCurrency->performReadonlyTransformation(); return $this; } From 405426799be5b95936cfa8d138d665d542fa2493 Mon Sep 17 00:00:00 2001 From: Joe Harvey Date: Mon, 13 Jan 2014 08:35:40 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Issue=20#2766=20-=20Moves=20logic=20to=20re?= =?UTF-8?q?turn=20ReadonlyField=20versions=20of=20MoneyFields=20child=20fi?= =?UTF-8?q?elds=20to=20performReadonlyTransformation()=20method=20and=20re?= =?UTF-8?q?verts=20changes=20to=20MoneyField::setReadonly()=20as=20per=20W?= =?UTF-8?q?ilr=E2=80=99s=20(https://github.com/wilr)=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- forms/MoneyField.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/forms/MoneyField.php b/forms/MoneyField.php index 703fbfcf1..fa7d9a88c 100644 --- a/forms/MoneyField.php +++ b/forms/MoneyField.php @@ -120,6 +120,8 @@ class MoneyField extends FormField { */ public function performReadonlyTransformation() { $clone = clone $this; + $clone->fieldAmount = $clone->fieldAmount->performReadonlyTransformation(); + $clone->fieldCurrency = $clone->fieldCurrency->performReadonlyTransformation(); $clone->setReadonly(true); return $clone; } @@ -131,8 +133,8 @@ class MoneyField extends FormField { public function setReadonly($bool) { parent::setReadonly($bool); - $this->fieldAmount = $this->fieldAmount->performReadonlyTransformation(); - $this->fieldCurrency = $this->fieldCurrency->performReadonlyTransformation(); + $this->fieldAmount->setReadonly($bool); + $this->fieldCurrency->setReadonly($bool); return $this; }