Custom field
If you make a custom field. Please share it with the community! (Make a PR)
Forget the label, help and error messages.
Don't create code for labels, help or error messages when creating a custom field, it's automatically added by the form component.
Extend existing component, instead of creating a custom field
If you are looking to change the styling of an existing field it is enough to extend the fields Blade Class or create your own theme.
Steps to create a custom field
1. Create a Field class that extends BaseField
Name your class in a non-conflicting and descriptive way
add the
$type
property, best practice is to slug case the class name.
2. Create a Blade component class, with the same name
Extend BaseBladeField
3. Create a blade component view
resources/views/components/my-field.blade.php
.Name the view the same as the field
$type
.You have access to all the
$field
attributes and methods, in your blade view.
Example using an input field based on MyField
blade component class:
4. Use your field in a form component
Please share your field!
If you make a new field. Please share it! Make a PR or paste the code in an issue, and I'll add it to the package.
Last updated
Was this helpful?