Blueprints
A blueprint lists the fields of an entry's form, and how each one is validated and saved. A collection names the
blueprints its entries can use in its blueprints list, and the first is the default. See
Collections.
Blueprints live outside the content root, at
resources/blueprints/collections/<collection>/<blueprint>.yaml. Change the folder with $blueprintPath in
app/Config/Content.php.
title: Post
fields:
- handle: title
type: text
label: Title
validate: required|max_length[255]
- handle: slug
type: slug
- handle: tagline
type: text
instructions: One line under the title.
- handle: featured
type: toggle
- handle: body
type: markdown
validate: required
Blueprint keys
| Key | What it does |
|---|---|
title |
The blueprint's name. Defaults to its filename. |
fields |
A list of fields, shown in this order. Give fields or sections, not both. |
sections |
Groups of fields, shown in this order. See Sections. |
seo |
Which fields feed an entry's SEO title and description. See SEO. |
Field keys
| Key | Default | What it does |
|---|---|---|
handle |
Required | The front matter key the value is saved under. Letters, numbers and _, starting with a letter. |
type |
Required | One of the field types. |
label |
The handle, as words | The label above the input. |
validate |
None | CodeIgniter validation rules, as required\|max_length[255] or as a list. |
instructions |
None | Help text under the input. |
width |
None | full makes the field span the whole row of its section. markdown and textarea fields do already. |
A type can read more keys, such as rows or time. They are listed with the type.
Sections
Group the fields of a long form with sections instead of fields. Each section has a title, and shows its fields in
one to three columns:
title: Post
sections:
- title: Content
instructions: What readers see first.
fields:
- handle: title
type: text
validate: required
- handle: slug
type: slug
- title: Details
columns: 2
fields:
- handle: featured
type: toggle
- handle: event_date
type: date
- handle: location
type: text
width: full
- handle: body
type: markdown
| Key | Default | What it does |
|---|---|---|
title |
Required | The heading of the section. |
instructions |
None | Help text under the heading. |
columns |
1 |
How many columns the fields are laid out in: 1, 2 or 3. |
fields |
Required | The section's fields, with the field keys above. |
Fields fill the columns in order, row by row. A field with width: full, and every markdown and textarea field,
takes a whole row instead. Below the md breakpoint the columns stack, one field to a row.
Sections only change how the form looks. The fields are saved flat, as front matter keys, exactly as they would be in a
blueprint with the same fields in one fields list. A handle can be used once in the whole blueprint, not once in each
section, and the seo mapping can name a field of any section. Everything that
reads a blueprint's fields, such as content:scaffold, sees them as one list. Taxonomy and global
blueprints can have sections too.
A blueprint that can't be loaded, because its YAML is invalid, a field has no handle, uses a type that doesn't exist
or repeats a handle, has both fields and sections, has a section without a title or with columns outside 1 to 3,
or has a width other than full, is refused with a message that says which. The entry form doesn't open, and the collection's list
still does.
Fields that aren't ordinary keys
body. A field with the handlebodyis the entry's Markdown body, the text after the front matter, not a key. Use amarkdownortextareafield for it. Without one the form doesn't show the body and saving keeps it.- A
slugfield is the file's name, not a key. See Slug. id,status,published_atandblueprintcan't be field handles. The form manages them: the id is made once, the status and publish date have their own inputs, andblueprintis written when the entry doesn't use the collection's default.title. A field with the handletitlebecomes the title in the list. Without one, the title is the slug.
An entry keeps the blueprint it was created with, in a blueprint key when it isn't the default.
Validation
The validate rules run in CodeIgniter's validator against the posted value, with the field's label in the message. A
type adds its own rules to yours, such as valid_date for a date. To read more, see
Validation rules.