Writing fields
Return the fields from thefields() method of the admin model. Each key is the name of a database column, the value is the field configuration combined with Laravel validation rules.
The configuration is written as a string of parameters separated by |, or as an array.
String notation
This notation is recommended for all fields.app/Models/Product.php
- A parameter without a value is a flag and becomes
true,requiredisrequired => true. - Values are always strings,
default:10becomes'10'. - Only the first colon separates the key, so
title:Opens at 10:30ordate_format:H:ikeep the rest of the value. - A repeated parameter becomes an array of values,
index:a|index:bisindex => ['a', 'b']. - Empty parts are ignored (
name:Name||required),placeholder:sets an empty string. - A value can not contain
|. Use the array notation when you need it.

Array notation
Each field can also be an array. Values keep their PHP types, and a value without a key is a flag.Method notation
Validation often differs between creating a record and editing it. Thefields() method receives the edited record as $row, which is null in the create form.
Combine the string notation with arrays when you need Laravel rule objects.
Field keys
The field key is the database column name. Keys are slugged with_ as the separator, so they are also lowercased:
Always use snake_case keys. The original camelCase key is not recognised in requests, in
getField() or as $row->firstName.
Field parameters
Every parameter which is not an admin parameter is passed to the Laravel validator as a rule, see validation rules. The admin parameters are documented on these pages:
Fields can be arranged into groups and tabs, and fields of an existing model can be changed with
mutateFields(), see groups and tabs.
Custom field parameters
A parameter which only expands into other parameters is a rule alias (custom_rules, global_rules). A parameter with its own logic is a field mutation: one class which changes every field carrying the parameter, in all models. Use a mutation instead of repeating the same change in mutateFields() of several models, and for every parameter a package adds.
app/Admin/Mutations/Money.php
update($field, $key, $model) changes the field, create($field, $key, $model) returns new fields key => field to add next to it, remove($field, $key, $model) returns true to drop the field. Inside the mutation $this->getModel(), $this->getKey() and $this->fields (all fields of the model) are available.
Fields are built once and cached, php artisan admin:cache compiles them in the console and long running processes keep them for the whole worker. A value which depends on the logged administrator or on data of the database belongs into a runtime mutation: it implements Admin\Core\Fields\Mutations\RuntimeMutation and is applied in the administration only, to fields with one of its $attributes, on top of the built fields.
$mutations of a package service provider, or in boot() of the application with Fields::addMutation(Money::class). A mutation is registered once, also when the application boots more times in one process.