slug is not generated within createOptionForm

slug is not generated within createOptionForm

Forms\Components\TextInput::make(name: 'name')
                                                                    ->required()
                                                                    ->maxlength(255)
                                                                    ->live(onBlur: true)
                                                                    ->unique(ignoreRecord: true)
                                                                    ->afterStateUpdated(function(string $operation, $state, Forms\Set $set) 
                                                                    {                                        
                                                                        if($operation !== 'create') {
                                                                            return;
                                                                        }
                                                                        $set('slug', Str::slug($state));
                                                                    }),

                                                                Forms\Components\TextInput::make(name: 'slug')
                                                                    ->disabled()
                                                                    ->dehydrated()
                                                                    ->required()
                                                                    ->maxlength(255)
                                                                    ->unique(table: Category::class, column: 'slug', ignoreRecord: true),


How do I solve this?
image.png
Was this page helpful?