Text
A standard, single-line input field
The text field creates a standard text input

Example
fields:
name:
label: Name
type: text
Field properties
Name | Type | Default | Description |
---|---|---|---|
$after | mixed |
null
|
Optional text that will be shown after the input |
$autofocus | bool |
null
|
Sets the focus on this field when the form loads. Only the first field with this label gets |
$before | mixed |
null
|
Optional text that will be shown before the input |
$converter | mixed |
null
|
The field value will be converted with the selected converter before the value gets saved. Available converters: lower , upper , ucfirst , slug
|
$counter | bool |
true
|
Shows or hides the character counter in the top right corner |
$default | mixed |
null
|
Default value for the field, which will be used when a page/file/user is created |
$disabled | bool |
null
|
If true , the field is no longer editable and will not be saved |
$font | string |
null
|
Sets the font family (sans or monospace) |
$help | mixed |
null
|
Optional help text below the field |
$icon | string |
null
|
Optional icon that will be shown at the end of the field |
$label | mixed |
null
|
The field label can be set as string or associative array with translations |
$maxlength | int |
null
|
Maximum number of allowed characters |
$minlength | int |
null
|
Minimum number of required characters |
$pattern | string |
null
|
A regular expression, which will be used to validate the input |
$placeholder | mixed |
null
|
Optional placeholder value that will be shown when the field is empty |
$required | bool |
null
|
If true , the field has to be filled in correctly to be saved. |
$spellcheck | bool |
false
|
If false , spellcheck will be switched off |
$translate | bool |
true
|
If false , the field will be disabled in non-default languages and cannot be translated. This is only relevant in multi-language setups. |
$when | mixed |
null
|
Conditions when the field will be shown (since 3.1.0) |
$width | string |
'1/1'
|
The width of the field in the field grid, e.g. 1/1 , 1/2 , 1/3 , 1/4 , 2/3 , 3/4
|
Length restrictions
You can control the maximal and/or minimal length of the entered text by using the maxlength
and/or minlength
option. A handy indicator of the current text length will be displayed in the upper right corner.
fields:
name:
label: Name
type: text
minlength: 10
maxlength: 1000
How to use in templates/snippets
Simple usage:
<?= $page->text() ?>
As with other fields, you can use Kirby's field methods to manipulate the output. Here are a few examples:
Escape the field value:
<?= $page->text()->escape() ?>
Convert to valid HTML:
<?= $page->text()->html() ?>
With fallback text if field is empty:
<?= $page->text()->or('Some fallback text') ?>
For more field manipulations, check out Kirby's field methods.