From 6bcabcbe463dbd828c4c48e39f8aaef697c3ebe6 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Sat, 27 Jun 2009 04:00:10 +0000 Subject: [PATCH] BUGFIX #4306 simon_w: Fixed ConfirmedPasswordField::setValue() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@80192 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/ConfirmedPasswordField.php | 5 ++++- tests/forms/ConfirmedPasswordFieldTest.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/forms/ConfirmedPasswordFieldTest.php diff --git a/forms/ConfirmedPasswordField.php b/forms/ConfirmedPasswordField.php index 766aea22b..ae0121a59 100644 --- a/forms/ConfirmedPasswordField.php +++ b/forms/ConfirmedPasswordField.php @@ -88,7 +88,8 @@ class ConfirmedPasswordField extends FormField { // we have labels for the subfields $title = false; - parent::__construct($name, $title, $value, $form); + parent::__construct($name, $title, null, $form); + $this->setValue($value); } function Field() { @@ -193,6 +194,8 @@ class ConfirmedPasswordField extends FormField { $this->value = $value; } } + $this->children->fieldByName($this->Name() . '[_Password]')->setValue($this->value); + $this->children->fieldByName($this->Name() . '[_ConfirmPassword]')->setValue($this->value); } function jsValidation() { diff --git a/tests/forms/ConfirmedPasswordFieldTest.php b/tests/forms/ConfirmedPasswordFieldTest.php new file mode 100644 index 000000000..cb7be3b68 --- /dev/null +++ b/tests/forms/ConfirmedPasswordFieldTest.php @@ -0,0 +1,17 @@ +assertEquals('valueA', $field->Value()); + $this->assertEquals('valueA', $field->children->fieldByName($field->Name() . '[_Password]')->Value()); + $this->assertEquals('valueA', $field->children->fieldByName($field->Name() . '[_ConfirmPassword]')->Value()); + $field->setValue('valueB'); + $this->assertEquals('valueB', $field->Value()); + $this->assertEquals('valueB', $field->children->fieldByName($field->Name() . '[_Password]')->Value()); + $this->assertEquals('valueB', $field->children->fieldByName($field->Name() . '[_ConfirmPassword]')->Value()); + } +}