FilamentF
Filament•15mo ago
Martin Oscar

use `configureUsing` to avoid repetition

I have many password fields in my application so i'd like to use
class AdminPanelProvider extends PanelProvider
{
    public function boot()
    TextInput::configureUsing(function (TextInput $component) {
        $component->isPassword() && $component->revealable(config('panel.password.revealable'));
        }, isImportant: true);
    }

Problem is this is the boot function runs BEFORE the component is created i want it to execute after so i don't have to manually add ->revealable(config('panel.password.revealable')) to every TextInput of the password kind.


I tried using
dump($component->isPassword());
and it will always return
false
same goes for
dump($component->getType());
it will always return
text
even though its a password, email or alphanumeric field.

I don't want to make my own component just for passwords cause i want to apply similar edit to other components as well

Thanks for your help 🙂
Was this page helpful?