From 18b3ee312946ec05b5b243903886095f2fd84e5c Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:15:22 +1200 Subject: [PATCH] FIX Update CMS fields now that they're being scaffolded (#198) --- code/BasicFieldsTestPage.php | 35 +++++++++++++++-------- code/FrameworkTestSiteTreeExtension.php | 10 ++++++- code/GridFieldTestPage.php | 10 +++++++ code/RelationFieldsTestPage.php | 10 +++++++ code/multitab-validation/MultiTabPage.php | 6 ++++ 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index 6eef58a..79caf29 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -41,8 +41,6 @@ class BasicFieldsTestPage extends TestPage private static $db = array( 'CalendarDate' => 'Date', 'Checkbox' => 'Boolean', - 'ConfirmedPassword' => 'Varchar', - 'CreditCard' => 'Varchar', 'Date' => 'Date', 'DateTime' => 'Datetime', 'DateTimeWithCalendar' => 'Datetime', @@ -64,8 +62,6 @@ class BasicFieldsTestPage extends TestPage 'MyLabelledFieldGroupCheckbox' => 'Boolean', 'Number' => 'Float', 'OptionSet' => 'Varchar', - 'Password' => 'Varchar', - 'PhoneNumber' => 'Varchar', 'Price' => 'Double', 'Readonly' => 'Varchar', 'Required' => 'Text', @@ -79,9 +75,7 @@ class BasicFieldsTestPage extends TestPage ); private static $has_one = array( - 'AttachedFile' => 'SilverStripe\\Assets\\File', 'Dropdown' => 'SilverStripe\\FrameworkTest\\Model\\TestCategory', - 'File' => 'SilverStripe\\Assets\\File', 'GroupedDropdown' => 'SilverStripe\\FrameworkTest\\Model\\TestCategory', 'Image' => 'SilverStripe\\Assets\\Image', ); @@ -97,11 +91,32 @@ class BasicFieldsTestPage extends TestPage ); private static $owns = [ - 'AttachedFile', - 'File', 'Image', ]; + private static array $scaffold_cms_fields_settings = [ + 'ignoreFields' => [ + 'MyCompositeField1', + 'MyCompositeField2', + 'MyCompositeField3', + 'MyCompositeFieldCheckbox', + 'MyFieldGroup1', + 'MyFieldGroup2', + 'MyFieldGroup3', + 'MyFieldGroupCheckbox', + 'MyLabelledFieldGroup1', + 'MyLabelledFieldGroup2', + 'MyLabelledFieldGroup3', + 'MyLabelledFieldGroupCheckbox', + 'ToggleCompositeTextField1', + 'ToggleCompositeDropdownField', + ], + 'ignoreRelations' => [ + 'CheckboxSet', + 'Listbox', + ], + ]; + private static $defaults = array( 'Validated' => 2 ); @@ -140,8 +155,6 @@ class BasicFieldsTestPage extends TestPage 'CalendarDate' => "2017-01-31", 'Checkbox' => 1, // 'CheckboxSet' => null, - 'ConfirmedPassword' => 'secret', - 'CreditCard' => '4000400040004111', 'Date' => "2017-01-31", 'DateTime' => "2017-01-31 23:59", 'DateTimeWithCalendar' => "2017-01-31 23:59", @@ -166,8 +179,6 @@ class BasicFieldsTestPage extends TestPage 'MyLabelledFieldGroupCheckbox' => true, 'Number' => 99.123, 'OptionSet' => $thirdCat->ID, - 'Password' => 'My value (ä!)', - 'PhoneNumber' => '021 1235', 'Price' => 99.99, 'Readonly' => 'My value (ä!)', 'Required' => 'My required value (delete to test)', diff --git a/code/FrameworkTestSiteTreeExtension.php b/code/FrameworkTestSiteTreeExtension.php index bb7b753..846b840 100644 --- a/code/FrameworkTestSiteTreeExtension.php +++ b/code/FrameworkTestSiteTreeExtension.php @@ -3,7 +3,15 @@ use SilverStripe\ORM\DataExtension; class FrameworkTestSiteTreeExtension extends DataExtension { - private static $has_one = array('RelationFieldsTestPage' => 'RelationFieldsTestPage'); private static $belongs_many_many = array('RelationFieldsTestPages' => 'RelationFieldsTestPage'); + + private static array $scaffold_cms_fields_settings = [ + 'ignoreFields' => [ + 'RelationFieldsTestPage', + ], + 'ignoreRelations' => [ + 'RelationFieldsTestPages', + ], + ]; } diff --git a/code/GridFieldTestPage.php b/code/GridFieldTestPage.php index 3ec93e5..f76e628 100644 --- a/code/GridFieldTestPage.php +++ b/code/GridFieldTestPage.php @@ -30,6 +30,16 @@ class GridFieldTestPage extends TestPage 'HasManyCompanies', ]; + private static array $scaffold_cms_fields_settings = [ + 'ignoreFields' => [ + 'HasOneCompany', + ], + 'ignoreRelations' => [ + 'HasManyCompanies', + 'ManyManyCompanies', + ], + ]; + public function getCMSFields() { $fields = parent::getCMSFields(); diff --git a/code/RelationFieldsTestPage.php b/code/RelationFieldsTestPage.php index df21513..8d21120 100644 --- a/code/RelationFieldsTestPage.php +++ b/code/RelationFieldsTestPage.php @@ -30,6 +30,16 @@ class RelationFieldsTestPage extends TestPage 'Title' => 'Relational Fields' ); + private static array $scaffold_cms_fields_settings = [ + 'ignoreFields' => [ + 'HasOneCompany', + ], + 'ignoreRelations' => [ + 'HasManyCompanies', + 'ManyManyCompanies', + ], + ]; + public function getCMSFields() { $fields = parent::getCMSFields(); diff --git a/code/multitab-validation/MultiTabPage.php b/code/multitab-validation/MultiTabPage.php index 91e0eeb..048c480 100644 --- a/code/multitab-validation/MultiTabPage.php +++ b/code/multitab-validation/MultiTabPage.php @@ -26,6 +26,12 @@ class MultiTabPage extends Page 'SettingsTabFirstField' => 'Varchar(50)', ]; + private static array $scaffold_cms_fields_settings = [ + 'ignoreFields' => [ + 'SettingsTabFirstField', + ], + ]; + public function getCMSFields() { $fields = parent::getCMSFields();