Choosing a type

The type 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.
Values longer than max (255 by default) are refused, empty input is saved as NULL.

Long text

A textarea without a length limit. Use longtext for content larger than 64 KB.

Rich-text editor

A CKEditor input stored as HTML. Use longeditor for a longtext column.
Editor fields are hidden in the listing table by default, add 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 the crudadmin/gutenberg package, which renders the blocks to HTML when the value is read on the website.
Unlike editor, the field is listed in the table unless you add hidden.

Integer

The value is cast to int. The column is unsigned when min is 0 or greater, unsigned is a shortcut for min:0.

Decimal

The column is decimal(8,2) unless decimal_length is set. Values are rounded to the scale by the database and cast to float.

Checkbox

The value is cast to 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 required password is required only while the record has no password, so it does not have to be typed again on every edit.
  • Only the password attribute of an authenticatable model (extending Admin\Eloquent\BaseAuthenticatable) is hashed automatically. On other models, and for other password fields, hash the value yourself, for example in a set{Key}Attribute mutator.

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

A 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

A spatial point column. Reading returns ['order' => 1, 'type' => 1, 'lng' => 17.1, 'lat' => 48.15]. Write values with a raw expression:
The field has no form input and is ignored by the admin search.

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.
When an existing field becomes imaginary, admin:migrate asks to drop its column (--auto-drop drops it without asking).
type:uploader is a field without a column too, see uploader.