mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Added unit tests for "_unchanged" handling in Form->loadDataFrom()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63762 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1665fd5cf3
commit
f49ed3ee17
@ -47,6 +47,31 @@ class FormTest extends FunctionalTest {
|
||||
$this->assertEquals($fields->fieldByName('othernamespace[key5][key6][key7]')->Value(), 'val7');
|
||||
}
|
||||
|
||||
public function testLoadDataFromUnchangedHandling() {
|
||||
$form = new Form(
|
||||
new Controller(),
|
||||
'Form',
|
||||
new FieldSet(
|
||||
new TextField('key1'),
|
||||
new TextField('key2')
|
||||
),
|
||||
new FieldSet()
|
||||
);
|
||||
$form->loadDataFrom(array(
|
||||
'key1' => 'save',
|
||||
'key2' => 'dontsave',
|
||||
'key2_unchanged' => '1'
|
||||
));
|
||||
$this->assertEquals(
|
||||
$form->getData(),
|
||||
array(
|
||||
'key1' => 'save',
|
||||
'key2' => null,
|
||||
),
|
||||
'loadDataFrom() doesnt save a field if a matching "<fieldname>_unchanged" flag is set'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLoadDataFromObject() {
|
||||
$form = new Form(
|
||||
new Controller(),
|
||||
|
Loading…
Reference in New Issue
Block a user