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()); + } +}