Skip to content

Kirby 6.0.0

List

A simple WYSIWYG editor field for ordered and unordered lists

Field options

Name Type Default Description
after arrayorstring null Optional text that will be shown after the input
autofocus bool false Sets the focus on this field when the form loads. Only the first field with this option gets focus
before arrayorstring null Optional text that will be shown before the input
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
help arrayorstring null Optional help text below the field
icon string null Optional icon that will be shown at the end of the field
label arrayorstring no default value The field label can be set as string or associative array with translations
marks arrayorbool null Sets the allowed HTML formats. Available formats: bold, italic, underline, strike, code, link, email. Activate/deactivate them all by passing true/false. Default marks are bold, italic, underline, strike, link, email
maxlength int null Maximum number of allowed characters
minlength int null Minimum number of required characters
nodes arrayorbool null Sets the allowed nodes. Available nodes: paragraph, heading, bulletList, orderedList, quote. Activate/deactivate them all by passing true/false. Default nodes are paragraph, heading, bulletList, orderedList.
placeholder arrayorstring null Optional placeholder value that will be shown when the field is empty
required bool false If true, the field has to be filled in correctly to be saved.
spellcheck bool null If false, spellcheck will be switched off
toolbar arrayorbool null Toolbar options, incl. marks (to narrow down which marks should have toolbar buttons), nodes (to narrow down which nodes should have toolbar dropdown entries) and inline to set the position of the toolbar (false = sticking on top of the field)
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

Example

fields:
  list:
    label: List
    type: list

Choosing available marks

The list field supports the following marks by default:

  • bold
  • italic
  • underline
  • strike
  • code
  • link
  • email
fields:
  list:
    type: list
    marks:
        - bold
        - italic
        - strike

How to use in templates/snippets

The content of the list field is stored as plain HTML. To render the field in your template, echo the value.

<?= $page->list() ?>

Update programmatically

To change the field value from PHP, pass an HTML list to $page->update():

$page->update([
  'list' => '<ul><li>First item</li><li>Second item</li></ul>'
]);