Configure which scaffolded fields are kept and which are removed.
Configure which scaffolded fields are kept and which are removed.
SilverStripe CMS creates CMS fields out of the box for you which is great for a quick project start up as you don't have to do anything to define your CMS fields.
This is covered by the field scaffolder which generates these scaffolded fields.
Many projects however, will use customised CMS fields which do not need the scaffolded fields.
On the contrary. scaffolded fields are often a hindrance.
In such situations, it's preferable to simply remove scaffolded fields and redefine them in your project code.
This approach makes the CMS fields definition more readable as all fields are defined in one place.
Project code is also easier to maintain as you don't have to support code which looks up scaffolded fields so they could be customised or reordered.
composer require silverstripe-terraformers/scaffolded-fields dev-master
Terraformers\ScaffoldedFields\Extension
to a data object of your choiceSpecify which fields need to be kept and which should be removed. Configuration is a collection of rules.
Each rule consists of the following:
db
, has_one
, has_many
, many_many
or extra
)keep
or remove
), this is not required when extra
property is usedDNADesign\Elemental\Models\BaseElement:
extensions:
- Terraformers\ScaffoldedFields\Extension
field_removal:
- # remove all db fields except Title and ShowTitle
property: db
type: keep
fields:
Title
ShowTitle
- # remove all has_one fields
property: has_one
type: keep
- # remove LinkTracking, FileTracking and BackLinkTracking fields from many_many
property: many_many
type: remove
fields:
LinkTracking
FileTracking
BackLinkTracking
- # remove Settings field (not part of any static property)
property: extra
fields:
Settings
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem