Skip to content

Field types

The type of a blueprint field decides how it looks in the form, how it's validated and how its value is saved in the front matter.

Type Input Saved as
text One line A string
textarea Several lines A string
markdown Several lines, with a preview A string, or the body
slug One line, filled from the title The file's name
toggle A switch true or false
date A date, or a date and time A string
datetime A date and time A string
select A dropdown, or a list to pick several from A string, or a list of them
integer A number A number
decimal A number with decimal places A string
belongsTo A dropdown of another model's records The record's ID
file A file picked from the media library The file's ID
image An image picked from the media library The file's ID
entries Entries to link to A list of UUIDs
terms A checkbox for each term A list of slugs
blocks The blocks written in the file A list of maps
list Rows you add, move, copy and delete A list of maps

You can add types of your own. See Custom field types.

A field left empty doesn't add a key to the file, though a key that is already there keeps its empty value.

Besides the keys every field has, each type reads the keys in its own table.

text

A single line of text. It has no keys of its own.

textarea

Several lines of text.

Key Default What it does
rows 6 The height of the input, in lines.

markdown

A textarea with a Preview tab that renders the text through CommonMark. Give it the handle body to edit the entry's body. See Editing entries.

Key Default What it does
rows 16 The height of the input, in lines.

slug

The entry's slug, which names its file and its URI. It isn't saved in the front matter, and it can't change once the entry exists, so the form shows it disabled.

Key Default What it does
from title The field the slug is made from.

On a new entry, the input fills itself from the from field as you type, until you type in it. Left empty, the slug is made from that field on the server. A slug is lowercase letters and numbers with - between, up to 100 characters, and the entry is refused if its file or URI is already taken.

toggle

A switch, which saves true or false. It has no keys of its own.

date

A date, saved as 2026-10-27. A value that isn't a date is refused.

Key Default What it does
time false With true, it's a date and time, saved as 2026-10-27 09:30:00 in your app's timezone.

datetime

A date and time, saved as 2026-10-27 09:30:00 in your app's timezone. It's a date field with time: true, under its own name, and has no keys of its own. A value that isn't a date and time is refused.

select

One option from a list, saved as a string, or several, saved as a list.

Key Default What it does
options None A list of values, or a map of value to label. The value is what the file holds and the label is what the form shows.
multiple false With true, the input is a list to pick several from, saved as a list.
- handle: mood
  type: select
  options: [happy, sad]
- handle: genre
  type: select
  options:
    sf: Science fiction
    fan: Fantasy
- handle: tags
  type: select
  multiple: true
  options: [php, yaml, css]

A value that isn't one of the options is refused. Values are saved as text, so an option 1 is saved as '1'. Add required to validate to make an empty choice an error.

integer

A whole number, saved as a number. A value that isn't a whole number, or is outside the bounds, is refused.

Key Default What it does
min None The lowest number allowed.
max None The highest number allowed.
- handle: rating
  type: integer
  min: 1
  max: 5

decimal

A number with a fixed count of decimal places, such as a price. It's saved as a string, "19.99", so it never passes through a float and can fill a DECIMAL column exactly. A value that isn't a number, has more places than places, or is below min is refused. The numbers are compared digit by digit, not as floats. Left empty, the value is null.

Key Default What it does
places 2 The most decimal places allowed. 0 allows whole numbers only.
min None The lowest value allowed.
step 0.01 The step of the input, which is 1 over 10 to the power of places unless you set it. The server doesn't check it, but the browser counts steps from min, so keep min a whole number of steps.
- handle: price
  type: decimal
  places: 2
  min: 0

Write the numbers as plain digits, such as 0.01 and not 1e-2. Read the value back as the string it is. A calculation that needs exactness should use a library such as bcmath, not the float PHP would cast it to.

belongsTo

One record of another model, such as the author of a post. The input is a dropdown of every record's title, and the file holds the record's ID.

Key Default What it does
model Required The class of a CodeIgniter model, such as App\Models\AuthorModel.
title Required The column of the model's table that names a record in the dropdown.
- handle: author
  type: belongsTo
  model: App\Models\AuthorModel
  title: name

The records come from the model's findAll(), ordered by the title, so a soft-deleted record isn't offered. A save is refused if the ID isn't a record of the model. The blueprint is refused if model isn't a model class, or title isn't a column of its table. An ID such as 7 is saved as a number, and any other, such as a UUID, as text.

Reading the entry gives the ID, not the record. To load the record in a template, ask the model for it:

<?php $author = model(App\Models\AuthorModel::class)->find($entry->field('author')); ?>

<?php if ($author !== null) : ?>
    <p>By <?= esc($author->name) ?></p>
<?php endif ?>

find() returns null when the field is empty or the record is gone, so check for that.

Many records

A dropdown of every record suits a table of a few hundred rows at most. Above searchAbove records (default 100) the input becomes a search box instead: type a few letters and it lists the records whose title contains them, at most 20, in title order. Choosing one saves its ID, and when you edit the entry the box shows the record's title.

Key Default What it does
searchAbove 100 How many records the model may have before the dropdown becomes a search box.
permission None A permission the user needs to search the records, on top of admin.access.
- handle: author
  type: belongsTo
  model: App\Models\AuthorModel
  title: name
  searchAbove: 50
  permission: authors.list

The search box asks GET /admin/fields/options for the matches. The request carries a token that Bonfire signed with the app's encryption key, naming the model, the title column, the column that is searched (the title) and the permission. A missing or changed token is refused with a 403, so the endpoint can't be made to read another model or column. Run php spark key:generate if the app has no key. Without JavaScript the search box is a plain input that takes the record's ID, and a save with an ID that isn't a record is refused.

file and image

One file from the media library. Choose opens a picker of the library's files, where the editor can search, open a folder, or upload a new file and pick it without leaving the form. An image field lists and accepts only images. A file field takes any file the library allows.

Key Default What it does
folder None The folder the picker opens on, and the folder an upload goes into.
- handle: photo
  type: image
  folder: products

The file holds the media file's ID, a UUID, so moving or renaming the file in the library doesn't break the link. A save is refused if the ID isn't a file in the library, or if an image field is given a file that isn't an image. A file that was deleted shows File not found in the form, and the entry can't be saved until the field is cleared or another file is chosen.

The picker needs the media.access permission, and its upload form media.edit.

Reading the entry gives the ID. To get the file in a template, use the media() helper. It returns null for an empty field or a deleted file:

<?php if ($photo = media($entry->field('photo'))) : ?>
    <img src="<?= esc($photo->url(), 'attr') ?>" alt="<?= esc($photo->alt ?? '', 'attr') ?>">
<?php endif ?>

entries

Links to other entries, saved as a list of their UUIDs.

Key Default What it does
collections Every collection The collections the form offers entries from, and accepts.
max_items None The most entries that can be linked. With 1 the form shows a dropdown instead of checkboxes.
- handle: related
  type: entries
  collections: [pages, blog]
  max_items: 3

The form lists every entry of those collections, drafts too, with a checkbox each. That suits collections of a few hundred entries. For more, change the input. A save is refused if it links an entry that doesn't exist, belongs to another collection, or takes the field over max_items.

Read the links back with $entry->entries('related'), which returns entry objects. A link whose entry is gone is skipped without an error, and saving the form drops it from the file.

A link to an entry in the trash survives a save. The form shows it checked and muted, marked "In trash", and you can untick it. A trashed entry is never offered as a new choice, and its link counts toward max_items. $entry->entries() skips it until it's restored, and then the link works again.

Upgrading

If you copied the entries input to your app's views before trashed links were kept, add what's new in fields/entries.php to your copy, or saving your form drops those links.

terms

The terms of a taxonomy an entry has, chosen from the terms that exist.

Key Default What it does
taxonomy Required The handle of the taxonomy.
- handle: tags
  type: terms
  taxonomy: tags

The input is a checkbox for each term. The front matter holds the checked slugs as a list under the taxonomy's handle, not under the field's handle, because that is where the reindex looks: tags: [php, laravel]. Unchecking every term saves tags: []. A slug in the file that no term has is shown as "(no such term)", checked, so that saving doesn't drop it. Anything posted that isn't a slug is dropped.

Use one terms field for each taxonomy. Don't name a taxonomy id, status, published_at, blueprint, title or body, which the entry uses itself, or the blueprint is refused.

For the entries to be indexed with their terms, the collection has to list the taxonomy in its taxonomies.

blocks

A list of blocks, each of a type with its own fields, saved as a list of maps with a type key.

Key Default What it does
blocks Every block type The block types the field allows, such as [hero, cta].
max_items None The most blocks there can be.
min_items None The fewest blocks there can be.
- handle: sections
  type: blocks
  blocks: [hero, cta]
  max_items: 10

Block types are files in resources/blueprints/blocks. The input is a list of cards that you add, move, copy and delete (see Editing blocks), and a field with max_items: 1 is a slot for a single block. A save is refused if there are too many or too few blocks, or if a block has a type the field doesn't allow or a value that fails its own field's rules. The blueprint is refused if a type has no file.

Read the blocks back with $entry->blocks('sections'), and render them with $entry->renderBlocks('sections'). For block types, partials and the rest, see Blocks.

list

A repeater: rows that all have the same fixed sub-fields, for repeated items such as features, FAQs, pricing tiers or logos. It's saved as a list of maps. Use it as a field of a blueprint or inside a block.

Key Default What it does
fields Required The sub-fields of each row, written like a blueprint's fields.
max_items None The most rows there can be.
min_items None The fewest rows there can be.
- handle: features
  type: list
  max_items: 6
  fields:
    - {handle: title, type: text, validate: required}
    - {handle: text, type: markdown}

A sub-field can be any type except slug, terms, blocks and list, and the blueprint is refused if it uses one of those. A row's keys are its own, so handles such as type and status are fine there. A save is refused if there are too many or too few rows, or if a value fails its sub-field's rules. For how the rows are edited, see Editing lists.

Read the rows back with field(), which returns a list of maps with every sub-field of every row, each value cast by its type: a toggle is a bool and an integer an int. A sub-field a row leaves out is null, or false for a toggle. It works the same on an entry, a block and a global set.

<?php foreach ($entry->field('features', []) as $feature) : ?>
    <h3><?= esc($feature['title']) ?></h3>
<?php endforeach ?>

Keys in a row that the sub-fields don't list aren't returned, and saving the form drops them from the file.

Changing an input

Each type's input is a partial in src/Fields/Views/fields, or in src/Content/Views/fields for slug, terms and entries. To change one, copy it to app/Views/fields/<type>.php, for example app/Views/fields/text.php. Bonfire uses your copy for every field of that type. The partial gets the variables listed at the top of the file it replaces: $field, $name, $id, $value and $disabled. It must name its input $name, and give it $id so the label points to it.

Writing your own

A type is a class that extends Bonfire\Fields\FieldType, and the built-in types are classes like this too. To write one, and for the methods a type can override, see Custom field types.