Created
February 29, 2024 21:48
-
-
Save RobMacKay/34c21b14b6571901d162566e021eaf05 to your computer and use it in GitHub Desktop.
FilamentPHP 3 Create Slug from Title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Forms\Components\TextInput::make('title') | |
->required() | |
->live(true) | |
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state))), | |
Forms\Components\TextInput::make('slug') | |
->disabled() | |
->dehydrated() | |
->maxLength(255) | |
->unique(Page::class, 'slug', ignoreRecord: true), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment