الصفحات · Laravilt
Creating Fields
Write the PHP class for a custom form field.
Generate the class
This creates app/Forms/Components/EmojiPicker.php, which extends Laravilt\Forms\Components\Field.
Add options
Store each option in a property and expose it in toLaraviltProps(). Closures are resolved with $this->evaluate():
Avoid method names that Field already defines with a different signature, such as max(), min(), color() or options(). PHP rejects incompatible overrides.
Component name
The props include a component key: the snake_case class name (emoji_picker). The frontend resolves it to the component registered as laravilt-emoji-picker. See Frontend Components.
Use it
Custom fields get every shared field feature: validation, live(), default(), visible() and so on.
Extend an existing field
To preconfigure a built-in field, extend it and override setUp(). It keeps the parent's frontend component: