I'm trying to create a repository composer package to create a custom form field for Voyager, and I found this example: https://github.com/bnku/extended-bread-form-fields , but this it doesn't work for me.
So, how do I build a custom field form for Voyager? The result would be this:
I tried this repository example.
https://github.com/bnku/extended-bread-form-fields (It didn't work for me)
and this is my repository test:
https://github.com/manuel90/crop-image-field
This is my composer.json of my package:
{
"name": "manuel90/crop-image-field",
"description": "New voyager form field to cut image when uploading",
"authors": [
{
"name": "Manuel",
"email": "testmlzra@gmail.com"
}
],
"require": {
"tcg/voyager": "^1.1"
},
"autoload": {
"psr-4": {
"Manuel90\\CropImageField\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Manuel90\\CropImageField\\CropImageFieldServiceProvider"
]
}
}
}
I can see these lines there's a trouble, it didn't detect the class "Voyager", but I don't know how to fix it:
if( class_exists('Voyager') ) {
Voyager::addFormField(CropImageFormField::class);
}
https://github.com/manuel90/crop-image-field/blob/master/src/CropImageFieldServiceProvider.php#L34-L36 ( According docs this is the way to add a custom form Docs here )
I expect to see in the BREAD edit section the new custom field listed on the input type option, like this: