Block Configuration (cms/blocks)
Each block type is configured in:
cms/blocks/<block_name>/config.yaml
The schema is defined in cms-bundle/src/Config/Model/Block.php.
Minimal Example
block:
revision: 1
This is the only required key. Everything else has defaults.
Practical Examples
Static singleton block rendered through a route:
block:
revision: 1
static: true
singleton: true
esi: true
render_url: user_dropdown
Configurable (non-static) block with form fields:
block:
revision: 1
render_template: '@block/cta/render.html.twig'
form_template: '@block/cta/form.html.twig'
form_fields:
title:
type: text
buttonLabel:
type: text
buttonUrl:
type: url
Option Reference
Top-level block keys:
revision(required, integer)render_template(optional, default:@block/<block_name>/render.html.twig)form_template(optional)esi(optional, default:true)ajax(optional, default:false)isolate_request(optional,true|false|null, default:null)cache_type(optional,public|private, default:public)cache_ttl(optional, integer, default:false)singleton(optional, default:true)static(optional, default:false)schedulable(optional, default:false)render_url(optional)form_fields(optional map of fields)
form_fields
Each field entry supports:
type(required)type_options(optional map)
Example:
form_fields:
heading:
type: translation
columns:
type: choice
type_options:
choices:
'2 columns': 2
'3 columns': 3
Validation Rules (Important)
The configuration model enforces these constraints:
- If
static: true, thensingletonmust also betrue. - If
static: true,form_fieldscannot be defined. - If
static: true,form_templatecannot be defined. - If
static: true,schedulablecannot betrue. isolate_requestcan only be set when at least one ofesiorajaxis enabled.- You cannot enable both
esi: trueandajax: trueat the same time.
How To Choose Options
- Use
static: truefor blocks that have no per-instance editable data. - Keep
singleton: truewhen the block should exist only once globally. - Use
form_fieldsonly for non-static blocks that editors need to customize. - Use
render_urlwhen rendering should be delegated to a Symfony route/controller. - Use
cache_typeandcache_ttlto control cache behavior for expensive blocks. - Use
isolate_request: trueonly when you need to avoid user-session context in sub-requests.
Notes
revisionis typically increased when block structure/behavior changes and migration logic is needed.- Most projects start with defaults and only override values that are functionally necessary.