afterStateUpdated after $set
Is there some way to trigger
afterStateUpdatedafterStateUpdated after using the $set$set?protected function getPasswordFormComponent(): Component
{
return TextInput::make('password')
->live()
->label(__('filament-panels::pages/auth/register.form.password.label'))
->type(fn (Get $get): string => $get('showPassword') ? 'text' : 'password')
->required()
->rule(Password::default())
->dehydrateStateUsing(fn ($state) => Hash::make($state))
->same('passwordConfirmation')
->validationAttribute(__('filament-panels::pages/auth/register.form.password.validation_attribute'))
->afterStateUpdated(function (string $state, Set $set, Get $get) {
$set('strengthScore', (new Zxcvbn())->passwordStrength($state)['score']);
})
->hintAction(
Action::make('generate')
->label('Generate')
->action(function (Set $set) {
$password = Str::password(12);
$set('password', $password);
$set('passwordConfirmation', $password);
}),
);
}protected function getPasswordFormComponent(): Component
{
return TextInput::make('password')
->live()
->label(__('filament-panels::pages/auth/register.form.password.label'))
->type(fn (Get $get): string => $get('showPassword') ? 'text' : 'password')
->required()
->rule(Password::default())
->dehydrateStateUsing(fn ($state) => Hash::make($state))
->same('passwordConfirmation')
->validationAttribute(__('filament-panels::pages/auth/register.form.password.validation_attribute'))
->afterStateUpdated(function (string $state, Set $set, Get $get) {
$set('strengthScore', (new Zxcvbn())->passwordStrength($state)['score']);
})
->hintAction(
Action::make('generate')
->label('Generate')
->action(function (Set $set) {
$password = Str::password(12);
$set('password', $password);
$set('passwordConfirmation', $password);
}),
);
}Solution
Why don't you move the
$set('strengthScore...$set('strengthScore... into the action?