Skip to content

Commit

Permalink
FIX Update CMS fields now that they're being scaffolded
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Aug 11, 2024
1 parent 19b1258 commit 229e7a6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
35 changes: 23 additions & 12 deletions code/BasicFieldsTestPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -64,8 +62,6 @@ class BasicFieldsTestPage extends TestPage
'MyLabelledFieldGroupCheckbox' => 'Boolean',
'Number' => 'Float',
'OptionSet' => 'Varchar',
'Password' => 'Varchar',
'PhoneNumber' => 'Varchar',
'Price' => 'Double',
'Readonly' => 'Varchar',
'Required' => 'Text',
Expand All @@ -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',
);
Expand All @@ -97,11 +91,32 @@ class BasicFieldsTestPage extends TestPage
);

private static $owns = [
'AttachedFile',
'File',
'Image',
];

private static array $scaffold_cmsfields_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
);
Expand Down Expand Up @@ -140,8 +155,6 @@ public function getDefaultData()
'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",
Expand All @@ -166,8 +179,6 @@ public function getDefaultData()
'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)',
Expand Down
10 changes: 9 additions & 1 deletion code/FrameworkTestSiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_cmsfields_settings = [
'ignoreFields' => [
'RelationFieldsTestPage',
],
'ignoreRelations' => [
'RelationFieldsTestPages',
],
];
}
10 changes: 10 additions & 0 deletions code/GridFieldTestPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class GridFieldTestPage extends TestPage
'HasManyCompanies',
];

private static array $scaffold_cmsfields_settings = [
'ignoreFields' => [
'HasOneCompany',
],
'ignoreRelations' => [
'HasManyCompanies',
'ManyManyCompanies',
],
];

public function getCMSFields()
{
$fields = parent::getCMSFields();
Expand Down
10 changes: 10 additions & 0 deletions code/RelationFieldsTestPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class RelationFieldsTestPage extends TestPage
'Title' => 'Relational Fields'
);

private static array $scaffold_cmsfields_settings = [
'ignoreFields' => [
'HasOneCompany',
],
'ignoreRelations' => [
'HasManyCompanies',
'ManyManyCompanies',
],
];

public function getCMSFields()
{
$fields = parent::getCMSFields();
Expand Down
6 changes: 6 additions & 0 deletions code/multitab-validation/MultiTabPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class MultiTabPage extends Page
'SettingsTabFirstField' => 'Varchar(50)',
];

private static array $scaffold_cmsfields_settings = [
'ignoreFields' => [
'SettingsTabFirstField',
],
];

public function getCMSFields()
{
$fields = parent::getCMSFields();
Expand Down

0 comments on commit 229e7a6

Please sign in to comment.