afterStateUpdated not work on custom field

Hi 👋, I've created a new “TypeCylinder” field in my form. It works fine, except that I can't get the afterStateUpdated() method to work, as it never seems to be called... Any idea why?

Here the input on the form :
CylinderType::make('content.cylinder_type.value')
    ->options(array(
        __('users/requests.field.1') => __('users/requests.field.1'),
        __('users/requests.field.2') => __('users/requests.field.2'),
        __('users/requests.field.3') => __('users/requests.field.3')
    ))
    ->hiddenLabel()
    ->afterStateUpdated(function (
        Set $set, $state
    ) {
        dd("Don't work :( ");
    })
    ->columnSpanFull()


The field class (CylinderType.php) :

namespace App\Forms\Components;

use Filament\Forms\Components\Concerns\HasOptions;
use Filament\Forms\Components\Field;

class CylinderType extends Field
{
    use HasOptions;
    protected string $view = 'forms.components.cylinder-type';
}
Solution
state should also be
state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$getStatePath()}')") }}
Was this page helpful?