FIX Ensure all fields are available for updateCMSFields(). (#1089)

This commit is contained in:
Guy Sartorelli 2022-03-03 16:47:45 +13:00 committed by GitHub
parent 243598f880
commit 60cd3d0937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 147 additions and 140 deletions

View File

@ -33,14 +33,14 @@ class EditableCheckbox extends EditableFormField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->replaceField('Default', CheckboxField::create( $fields->replaceField('Default', CheckboxField::create(
"CheckedDefault", "CheckedDefault",
_t('SilverStripe\\UserForms\\Model\\EditableFormField.CHECKEDBYDEFAULT', 'Checked by Default?') _t('SilverStripe\\UserForms\\Model\\EditableFormField.CHECKEDBYDEFAULT', 'Checked by Default?')
)); ));
});
return $fields; return parent::getCMSFields();
} }
public function getFormField() public function getFormField()

View File

@ -5,6 +5,7 @@ namespace SilverStripe\UserForms\Model\EditableFormField;
use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField; use SilverStripe\Forms\TextField;
use SilverStripe\i18n\i18n; use SilverStripe\i18n\i18n;
use SilverStripe\UserForms\Model\EditableCustomRule; use SilverStripe\UserForms\Model\EditableCustomRule;
@ -35,8 +36,7 @@ class EditableCountryDropdownField extends EditableFormField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName('Default'); $fields->removeByName('Default');
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Main', 'Root.Main',
@ -55,8 +55,9 @@ class EditableCountryDropdownField extends EditableFormField
'Root.Main', 'Root.Main',
TextField::create('EmptyString', _t(__CLASS__ . '.EMPTY_STRING', 'Empty String')) TextField::create('EmptyString', _t(__CLASS__ . '.EMPTY_STRING', 'Empty String'))
); );
});
return $fields; return parent::getCMSFields();
} }
public function getFormField() public function getFormField()

View File

@ -36,8 +36,7 @@ class EditableDropdown extends EditableMultipleOptionField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Main', 'Root.Main',
CheckboxField::create('UseEmptyString') CheckboxField::create('UseEmptyString')
@ -51,8 +50,9 @@ class EditableDropdown extends EditableMultipleOptionField
); );
$fields->removeByName('Default'); $fields->removeByName('Default');
});
return $fields; return parent::getCMSFields();
} }
/** /**

View File

@ -3,6 +3,7 @@
namespace SilverStripe\UserForms\Model\EditableFormField; namespace SilverStripe\UserForms\Model\EditableFormField;
use SilverStripe\Core\Convert; use SilverStripe\Core\Convert;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\LabelField; use SilverStripe\Forms\LabelField;
use SilverStripe\UserForms\FormField\UserFormsGroupField; use SilverStripe\UserForms\FormField\UserFormsGroupField;
use SilverStripe\UserForms\Model\EditableFormField; use SilverStripe\UserForms\Model\EditableFormField;
@ -46,9 +47,11 @@ class EditableFieldGroup extends EditableFormField
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']); $fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']);
return $fields; });
return parent::getCMSFields();
} }
public function getCMSTitle() public function getCMSTitle()

View File

@ -2,6 +2,7 @@
namespace SilverStripe\UserForms\Model\EditableFormField; namespace SilverStripe\UserForms\Model\EditableFormField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\LabelField; use SilverStripe\Forms\LabelField;
use SilverStripe\Security\Group; use SilverStripe\Security\Group;
@ -50,9 +51,11 @@ class EditableFieldGroupEnd extends EditableFormField
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']); $fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']);
return $fields; });
return parent::getCMSFields();
} }
public function getInlineClassnameField($column, $fieldClasses) public function getInlineClassnameField($column, $fieldClasses)

View File

@ -141,8 +141,7 @@ class EditableFileField extends EditableFormField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$treeView = TreeDropdownField::create( $treeView = TreeDropdownField::create(
'FolderID', 'FolderID',
_t(__CLASS__.'.SELECTUPLOADFOLDER', 'Select upload folder'), _t(__CLASS__.'.SELECTUPLOADFOLDER', 'Select upload folder'),
@ -175,8 +174,9 @@ class EditableFileField extends EditableFormField
); );
$fields->removeByName('Default'); $fields->removeByName('Default');
});
return $fields; return parent::getCMSFields();
} }
/** /**

View File

@ -40,8 +40,7 @@ class EditableFormHeading extends EditableFormField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName(['Default', 'Validation', 'RightTitle']); $fields->removeByName(['Default', 'Validation', 'RightTitle']);
$levels = [ $levels = [
@ -64,8 +63,9 @@ class EditableFormHeading extends EditableFormField
_t('SilverStripe\\UserForms\\Model\\EditableFormField\\EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?') _t('SilverStripe\\UserForms\\Model\\EditableFormField\\EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?')
) )
]); ]);
});
return $fields; return parent::getCMSFields();
} }
public function getFormField() public function getFormField()

View File

@ -34,11 +34,11 @@ class EditableFormStep extends EditableFormField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName(['MergeField', 'Default', 'Validation', 'RightTitle']); $fields->removeByName(['MergeField', 'Default', 'Validation', 'RightTitle']);
});
return $fields; return parent::getCMSFields();
} }
/** /**

View File

@ -118,8 +118,7 @@ class EditableLiteralField extends EditableFormField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName(['Default', 'Validation', 'RightTitle']); $fields->removeByName(['Default', 'Validation', 'RightTitle']);
$fields->addFieldsToTab('Root.Main', [ $fields->addFieldsToTab('Root.Main', [
@ -135,8 +134,9 @@ class EditableLiteralField extends EditableFormField
_t(__CLASS__.'.HIDELABEL', "Hide 'Title' label on frontend?") _t(__CLASS__.'.HIDELABEL', "Hide 'Title' label on frontend?")
) )
]); ]);
});
return $fields; return parent::getCMSFields();
} }
public function getFormField() public function getFormField()

View File

@ -32,8 +32,7 @@ class EditableMemberListField extends EditableFormField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName('Default'); $fields->removeByName('Default');
$fields->removeByName('Validation'); $fields->removeByName('Validation');
@ -46,8 +45,9 @@ class EditableMemberListField extends EditableFormField
Group::get()->map() Group::get()->map()
)->setEmptyString(' ') )->setEmptyString(' ')
); );
});
return $fields; return parent::getCMSFields();
} }
public function getFormField() public function getFormField()

View File

@ -26,11 +26,11 @@ class EditableRadioField extends EditableMultipleOptionField
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName('Default'); $fields->removeByName('Default');
});
return $fields; return parent::getCMSFields();
} }
public function getFormField() public function getFormField()