F
Filament5mo ago
Sector

JS in login page

Hey! I created a new login page and I would like to config it a little bit. Maybe when an error message pops up, the Login button will dissapears. So my question is, there is any way to change the components behaviour with some Javascript code? Thanks for the answers!
11 Replies
toeknee
toeknee5mo ago
Just add the JS to the page? OR condition the submit button based on the action happening
Sector
SectorOP5mo ago
It's should happen after the user hitting the Login button.
toeknee
toeknee5mo ago
So you want to disable when theres an error and how should it be re-enabled?
Sector
SectorOP5mo ago
I don't want to re-enable it. When the user hitting the Login button, he will get a magic link via email, which helps him to logging in. So I just want to disable the button, to avoid spam.
toeknee
toeknee5mo ago
Medium
How to disable button on click with AlpineJS
Sometimes, we want to disable a button on click to avoid double-entry submission. This is especially critical on forms that would create…
Sector
SectorOP5mo ago
And how do I add JS to the Login page?
Tetracyclic
Tetracyclic5mo ago
You can provide your own Filament page to the login() method on the panel, extending the original login class and overriding anything you need to, including providing your own view: https://filamentphp.com/docs/3.x/panels/users#authentication-features
Tetracyclic
Tetracyclic5mo ago
You could also potentially use the PanelsRenderHook::AUTH_LOGIN_FORM_AFTER or PanelsRenderHook::AUTH_LOGIN_FORM_BEFORE render hooks
Sector
SectorOP5mo ago
Yeah, I already did that, but the question is, where should I write the Javascript code, to change the components behaviour?
toeknee
toeknee5mo ago
So you add it in the blade file.... if you need to add it to form emlements then use ->extraAttributes([])
Sector
SectorOP5mo ago
Thanks for the help, all clear.
Want results from more Discord servers?
Add your server