Custom field with HasAffixes trait
Trying to set up this custom field and want to add a prefix $ icon. I can't seem to get a prefix to work on this field and wondering what I'm doing wrong.
Solution:Jump to solution
You need to pass the prefix to the wrapper since you’re in a custom view. See https://github.com/filamentphp/filament/blob/3.x/packages/forms/resources/views/components/text-input.blade.php
GitHub
filament/packages/forms/resources/views/components/text-input.blade...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
6 Replies
Solution
You need to pass the prefix to the wrapper since you’re in a custom view. See https://github.com/filamentphp/filament/blob/3.x/packages/forms/resources/views/components/text-input.blade.php
GitHub
filament/packages/forms/resources/views/components/text-input.blade...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
hmmm...when I do this:
I get the error: "str_contains(): Argument #1 ($haystack) must be of type string, Closure given"
Did you define $prefixIcon = $getPrefixIcon()
Or just pass in $getPrefixIcon()
I want to define it in the component itself, but I'm evidently doing that wrong:
Right, that is fine. But in your blade file the method is $getPrefixIcon(). In the link I sent it is being set at the top of the file.
ahh ok...I get it now...that works, thanks!