Skip to content

Kirby 6.0.0

Entries

The entries field allows you to create and manage multiple entries for the same field.

Field options

Name Type Default Description
autofocus bool false Sets the focus on this field when the form loads. Only the first field with this option gets focus
default mixed null Default value for the field, which will be used when a page/file/user is created
disabled bool false If true, the field is no longer editable
empty arrayorstring null Sets the text for the empty state box
field arrayorstring ['type' => 'text'] Field options for the field to be used and repeated. Supported field types are color, date, email, number, select, slug, tel, text, time, url.
help arrayorstring null Optional help text below the field
label arrayorstring no default value The field label can be set as string or associative array with translations
max int null Sets the maximum number of allowed items in the field
min int null Sets the minimum number of required items in the field
required bool false If true, the field has to be filled in correctly to be saved.
sortable bool true If true, entries are sortable via drag & drop
translate bool true Should the field be translatable?
validate arrayorstring null Additional validator rules for the value, e.g. email or ['minLength' => 3]
when array null Conditions when the field will be shown
width string '1/1' The width of the field in the field grid. Available widths: 1/1, 1/2, 1/3, 1/4, 2/3, 3/4

The entries field allows you to create and manage multiple entries for the same field. It offers editors a flexible alternative to the structure field for when they need to handle a list of content that only consists of one field.

Usage

entries:
  type: entries
  min: 2
  max: 4
  required: true
  field:
    type: select
    options:
      design: Design
      architecture: Architecture
      photography: Photography
      3d: 3D
      web: Web

In templates/snippets

To easily loop through your entries and retrieve each entry as field object, you can use the new $field->toEntries() method:

<ul>
  <?php foreach ($page->entries()->toEntries() as $entry): ?>
    <li><?= $entry->upper() ?></li>
  <?php endforeach ?>
</ul>

Update programmatically

To change the field value from PHP, pass an array of values to $page->update():

$page->update([
  'entries' => ['design', 'architecture']
]);