Field component
When you need your own input, render the field with a Vue component. Components are plain.vue files, CrudAdmin loads them without a build step.
Create the component with an artisan command:
app/Models/Product.php
resources/views/admin/components/fields/ProductDimensions.vue
model, field, field_key and row props. Field properties are reactive, so the component can also change them, e.g. this.field.hideFromForm = true.
Where components are loaded from
- by name from the directories in the
componentsconfiguration,component:ProductDimensions, - a dot is a subdirectory,
component:Products.DimensionsloadsProducts/Dimensions.vue, - the file name is case-insensitive and found in any subdirectory,
- an absolute path,
'component:'.resource_path('js/admin/Dimensions.vue').
Rendering next to the native input
sub_component renders the component below the native input instead of replacing it, e.g. to react on the field value.
component with an empty <template></template> behaves the same way: the native input stays and your component runs next to it.
Table cell component
column_component renders the listing cell with your component. The row value is loaded as usual, the columns.{key}.component model setting overrides the parameter.
Filtering options of a select
A component can hide options of a select withmodel.optionsFilter(key, filter).
The filter is a list of hidden option keys, or a function returning false for hidden options.
resources/views/admin/components/fields/StageFilter.vue