F
Filament2w ago
pjb

Changing Field Wrapper View for Form Component Throws Exception

What I am trying to do: I am trying to use the fieldWrapperView() method on a Select form component to change which blade file gets used for the field wrapper. What I did: I copied vendor/filament/forms/resources/views/components/field-wrapper/index.blade.php to resources/views/filament/field-wrapper.blade.php then updated the Select to:
Forms\Components\Select::make('city')
->view('filament.address-verify-city-select')
->fieldWrapperView('filament.field-wrapper')
Forms\Components\Select::make('city')
->view('filament.address-verify-city-select')
->fieldWrapperView('filament.field-wrapper')
I also tried various different directory/sub-directory structures and naming conventions in my resources/views and fieldWrapperView() calls to make it work, to no avail. I have another blade template in the same directory, which I use in the ->view('filament.address-verify-city-select') call and that works just fine.
My issue / the error:
InvalidArgumentException
Unable to locate a class or view for component [filament.field-wrapper].
InvalidArgumentException
Unable to locate a class or view for component [filament.field-wrapper].
Appreciate any help! Thanks!
4 Replies
toeknee
toeknee2w ago
did you clear the cache?
pjb
pjbOP2w ago
@toeknee Definitely! I've called both optimize:clear and filament:optimize-clear multiple times. Have you gotten fieldWrapperView() to work correctly?
awcodes
awcodes2w ago
field wrapper is a dynamic component so it has to be in 'resources/views/components' to work the way you are trying to make it work. that's a convention of laravel. make sure you really need to override the component too. overriding filament's components is not recommended unless you know what you are doing and are will to take on the responsibility of possible breaking changes in the future.
pjb
pjbOP2w ago
Thank you @awcodes! That did it. @awcodes Fully understand the warning and the consequences. Thanks for looking out!
Want results from more Discord servers?
Add your server