Choosing a type
Thetype parameter decides the database column, the cast, the default validation rules and the form input.
A field without type is a string. Some parameters set the type for you, for example image sets type:file
and belongsTo sets type:select.
Every type adds its default rules (string adds max:255, integer adds integer|max:4294967295). Parameters written
on the field win, so max:1000 on a string creates varchar(1000).
Columns are nullable unless the field is
required. A type which is not in this list is skipped by admin:migrate
with an Unknown field type message.
Text
A single line input.type:string is the default and does not have to be written.
max (255 by default) are refused, empty input is saved as NULL.
Long text
A textarea without a length limit. Uselongtext for content larger than 64 KB.
Rich-text editor
A CKEditor input stored as HTML. Uselongeditor for a longtext column.
column_visible to show them.
On the website the value is wrapped in <div data-crudadmin-editor>...</div>, which enables inline editing for logged
administrators. In the administration and in console the raw HTML is returned.
Block editor
A Gutenberg block editor. Install thecrudadmin/gutenberg package, which renders the blocks to HTML when the value is read on the website.
editor, the field is listed in the table unless you add hidden.
Integer
int. The column is unsigned when min is 0 or greater, unsigned is a shortcut for min:0.
Decimal
decimal(8,2) unless decimal_length is set. Values are rounded to the scale by the database
and cast to float.
Checkbox
bool. A checkbox missing in the submitted admin form is saved as false.
type:boolean was removed in v6. Use type:checkbox and review the upgrade notes.Password
- The value is never sent to the administration, it is hidden in the table and in form responses.
- Leaving the input empty when editing keeps the current password. A
requiredpassword is required only while the record has no password, so it does not have to be typed again on every edit. - Only the
passwordattribute of an authenticatable model (extendingAdmin\Eloquent\BaseAuthenticatable) is hashed automatically. On other models, and for other password fields, hash the value yourself, for example in aset{Key}Attributemutator.
Color and phone
color stores a hex value like #ff0000 (max 7 characters). phone stores up to 20 characters and is rendered as a tel: link in the table.
JSON data
json column cast to an array, hidden in the table and without a form input, render it with a custom component.
A JSON string sent in the request is decoded before saving, an invalid JSON string is saved as NULL.
type:array was removed in v6. See Upgrade guide → v6 before updating existing fields.Geometry
point column. Reading returns ['order' => 1, 'type' => 1, 'lng' => 17.1, 'lat' => 48.15].
Write values with a raw expression:
Fields without a column
type:imaginary, or the imaginary parameter on any type, adds a form field without a database column. Use it for helper
fields and custom components. The value is not fillable and a posted value is ignored when saving.
admin:migrate asks to drop its column (--auto-drop drops it without asking).