mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
API Mark EditableFormField::EffectiveDisplayRules() for deprecation
This commit is contained in:
parent
a0cedaeb38
commit
793f437289
@ -55,3 +55,9 @@ mappings:
|
|||||||
EditableLiteralFieldTest: SilverStripe\UserForms\Tests\Model\EditableFormField\EditableLiteralFieldTest
|
EditableLiteralFieldTest: SilverStripe\UserForms\Tests\Model\EditableFormField\EditableLiteralFieldTest
|
||||||
SecureEditableFileFieldTest: SilverStripe\UserForms\Tests\Model\EditableFormField\SecureEditableFileFieldTest
|
SecureEditableFileFieldTest: SilverStripe\UserForms\Tests\Model\EditableFormField\SecureEditableFileFieldTest
|
||||||
UserDefinedForm_EmailRecipientConditionTest: SilverStripe\UserForms\Tests\Model\Recipient\EmailRecipientConditionTest
|
UserDefinedForm_EmailRecipientConditionTest: SilverStripe\UserForms\Tests\Model\Recipient\EmailRecipientConditionTest
|
||||||
|
|
||||||
|
warnings:
|
||||||
|
methods:
|
||||||
|
'SilverStripe\UserForms\Model\EditableFormField->EffectiveDisplayRules()':
|
||||||
|
message: 'EffectiveDisplayRules deprecated because of new support for conditional required field'
|
||||||
|
url: 'https://github.com/silverstripe/silverstripe-userforms/pull/770/'
|
||||||
|
@ -926,6 +926,20 @@ class EditableFormField extends DataObject
|
|||||||
->setRecord($this);
|
->setRecord($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine effective display rules for this field.
|
||||||
|
*
|
||||||
|
* @return SS_List
|
||||||
|
* @deprecated 5.6 No longer needed because of support for conditional required field.
|
||||||
|
*/
|
||||||
|
public function EffectiveDisplayRules()
|
||||||
|
{
|
||||||
|
if ($this->Required) {
|
||||||
|
return ArrayList::create();
|
||||||
|
}
|
||||||
|
return $this->DisplayRules();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts info from DisplayRules into array so UserDefinedForm->buildWatchJS can run through it.
|
* Extracts info from DisplayRules into array so UserDefinedForm->buildWatchJS can run through it.
|
||||||
* @return array|null
|
* @return array|null
|
||||||
|
@ -73,12 +73,19 @@ class EditableFormFieldTest extends FunctionalTest
|
|||||||
// it has 1 rule - when ticked the checkbox hides the text field
|
// it has 1 rule - when ticked the checkbox hides the text field
|
||||||
$this->assertEquals(1, $rules->Count());
|
$this->assertEquals(1, $rules->Count());
|
||||||
|
|
||||||
|
// EffectiveDisplayRules rule has been deprecated
|
||||||
|
$this->assertEquals($rules, $checkbox->EffectiveDisplayRules());
|
||||||
|
|
||||||
$checkboxRule = $rules->First();
|
$checkboxRule = $rules->First();
|
||||||
$checkboxRule->ConditionFieldID = $field->ID;
|
$checkboxRule->ConditionFieldID = $field->ID;
|
||||||
|
|
||||||
$this->assertEquals($checkboxRule->Display, 'Hide');
|
$this->assertEquals($checkboxRule->Display, 'Hide');
|
||||||
$this->assertEquals($checkboxRule->ConditionOption, 'HasValue');
|
$this->assertEquals($checkboxRule->ConditionOption, 'HasValue');
|
||||||
$this->assertEquals($checkboxRule->FieldValue, '6');
|
$this->assertEquals($checkboxRule->FieldValue, '6');
|
||||||
|
|
||||||
|
// If field is required then all custom rules are disabled
|
||||||
|
$checkbox->Required = true;
|
||||||
|
$this->assertEquals(0, $checkbox->EffectiveDisplayRules()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEditableOptionEmptyValue()
|
public function testEditableOptionEmptyValue()
|
||||||
@ -285,5 +292,4 @@ class EditableFormFieldTest extends FunctionalTest
|
|||||||
$field = $this->objFromFixture(EditableTextField::class, $fieldName);
|
$field = $this->objFromFixture(EditableTextField::class, $fieldName);
|
||||||
$this->assertEquals($expected, $field->isDisplayed($data));
|
$this->assertEquals($expected, $field->isDisplayed($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user