How can I get started with a JS field?
I want to create my own filament field (Slider) which is based on JS nouislider
This is currently an Issue on github for filament 4.1. I want to get a jumpstart on this, and even if it doesnt get merged, at least I learned something new 😅
The problem is I have NO IDEA how to get started with javascript plugins. For starters, I added nouislider in the package.json. Furthermore, I've also create the Slider class, blade and JS file as follows:
packages/forms/src/Components/Slider.php
packages/forms/resources/js/components/slider.js
packages/forms/resources/views/components/slider.blade.php
In the create page, I have the Slider field, but when the page is loaded I get this error:
Alpine component with ID [slider] not found for package [filament/forms].
What am I missing? Can anyone help?17 Replies
Ok thanks.
But when I open the browser I get this on the console:

Which is weird because Ive already added the nouislider in the devdependencies
It's not so weird, it can't find it... the url diesn't exist
any idea why that is?
Have I missed some step?
I also ran
node bin/build.js
to create the slider.js in /distLooks like your slider.js hasn't been deployed to /forms/components/

You shouldn't be placing it there really as it's not part of the package why would it be put there? Have a look at how to include js in filament:
https://filamentphp.com/docs/3.x/support/assets#registering-javascript-files
Ive already added it in the FormsServiceProvider
Should it also be somewhere else?
I kindda want to follow the same approach as these.

Hm okay, I ran
php artisan filament:assets
and now I get the JS file 🎉However, I dont see it

Could you help please? @toeknee

Fixed it!
Thanks for your help!