mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: ConfirmedPassword field correctly reports mismatching passwords
added testFormValidation to prove #4780
This commit is contained in:
parent
b943a0c6dd
commit
e9b833f5f0
@ -264,6 +264,7 @@ class ConfirmedPasswordField extends FormField {
|
||||
} else {
|
||||
if($value || (!$value && $this->canBeEmpty)) {
|
||||
$this->value = $value;
|
||||
$this->confirmValue = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +274,7 @@ class ConfirmedPasswordField extends FormField {
|
||||
->setValue($this->value);
|
||||
|
||||
$this->children->fieldByName($this->getName() . '[_ConfirmPassword]')
|
||||
->setValue($this->value);
|
||||
->setValue($this->confirmValue);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -71,5 +71,25 @@ class ConfirmedPasswordFieldTest extends SapphireTest {
|
||||
));
|
||||
$this->assertFalse($field->validate($validator));
|
||||
}
|
||||
|
||||
public function testFormValidation() {
|
||||
$form = new Form(
|
||||
new Controller(),
|
||||
'Form',
|
||||
new FieldList($field = new ConfirmedPasswordField('Password')),
|
||||
new FieldList()
|
||||
);
|
||||
|
||||
$form->loadDataFrom(array(
|
||||
'Password' => array(
|
||||
'_Password' => '123',
|
||||
'_ConfirmPassword' => '999',
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertEquals('123', $field->children->first()->Value());
|
||||
$this->assertEquals('999', $field->children->last()->Value());
|
||||
$this->assertNotEquals($field->children->first()->Value(), $field->children->last()->Value());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user