Terraformers\ScaffoldedFields\Extension
Class Extension
Removal of scaffolded fields
this is useful for project setup where scaffolded fields are not needed
there are various options on how to remove scaffolded fields
Note that this extension needs to be applied manually and order matters
you want to apply this extension after all scaffolded fields are present not before your model level
fields customisation
example config
DNADesign\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
Synopsis
- // constants
- const TYPE_KEEP = 'keep';
- const TYPE_REMOVE = 'remove';
- // members
- private static array $field_removal = ;
- // methods
- public void updateCMSFields()
- private void removeFields()
- private void removeDbFields()
- private bool validateRule()
Hierarchy
Extends
- SilverStripe\ORM\DataExtension
Constants
Name | Value |
---|---|
TYPE_KEEP | 'keep' |
TYPE_REMOVE | 'remove' |
Members
private
- $field_removal
—
array
Specify which scaffolded fields need to be kept and which should be removed configuration is a collection of rules each rules has consist of the following - property (db, has_one, has_many, many_many or extra) - type (keep or remove), this is not required when extra property is used - fields list of field names that the configuration applies to