terraformers / scaffolded-fields
Configure which scaffolded fields are kept and which are removed.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 10
Forks: 0
Open Issues: 22
Type:silverstripe-vendormodule
Requires
- php: ^7.1
- silverstripe/admin: ^1.0
- silverstripe/framework: ^4.0
- silverstripe/vendor-plugin: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^3.0
- dev-master / 1.x-dev
- 1.0.0
- dev-dependabot/npm_and_yarn/qs-6.5.3
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/css-what-2.1.3
- dev-dependabot/npm_and_yarn/ws-5.2.3
- dev-dependabot/npm_and_yarn/async-2.6.4
- dev-dependabot/npm_and_yarn/tmpl-1.0.5
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/tar-2.2.2
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/lodash-4.17.21
- dev-dependabot/npm_and_yarn/handlebars-4.7.7
- dev-dependabot/npm_and_yarn/y18n-3.2.2
- dev-dependabot/npm_and_yarn/elliptic-6.5.4
- dev-dependabot/npm_and_yarn/ini-1.3.8
- dev-dependabot/npm_and_yarn/npm-user-validate-1.0.1
- dev-dependabot/npm_and_yarn/node-sass-4.14.1
- dev-dependabot/npm_and_yarn/bin-links-1.1.8
- dev-dependabot/npm_and_yarn/npm-6.14.6
- dev-dependabot/npm_and_yarn/https-proxy-agent-2.2.4
- dev-dependabot/npm_and_yarn/fstream-1.0.12
- dev-dependabot/npm_and_yarn/lodash.mergewith-4.6.2
- dev-dependabot/npm_and_yarn/mixin-deep-1.3.2
This package is not auto-updated.
Last update: 2024-10-29 17:15:06 UTC
README
Configure which scaffolded fields are kept and which are removed.
Overview
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.
Most notable cases
- inserting new fields to specific position
- changing the order of scaffolded
- changing the hierarchy of scaffolded
Conclusion
- customising scaffolded fields takes more effort compared to defining them from scratch
- customising order of the scaffolded fields takes more effort compared to defining it from scratch
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.
Installation
composer require silverstripe-terraformers/scaffolded-fields dev-master
- apply
Terraformers\ScaffoldedFields\Extension
to a data object of your choice - provide field removal configuration
Configuration
Specify which fields need to be kept and which should be removed. Configuration is a collection of rules. Each rule consists of the following:
- property (
db
,has_one
,has_many
,many_many
orextra
) - type (
keep
orremove
), this is not required whenextra
property is used - fields list of field names that the configuration applies to
Example configuration
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