mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4788 from christopherdarling/patch-5
FIX: for ConfirmedPasswordField validation
This commit is contained in:
commit
e0d7400aea
@ -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