Skip to content

Instantly share code, notes, and snippets.

@RobMacKay
Created February 29, 2024 21:48
Show Gist options
  • Save RobMacKay/34c21b14b6571901d162566e021eaf05 to your computer and use it in GitHub Desktop.
Save RobMacKay/34c21b14b6571901d162566e021eaf05 to your computer and use it in GitHub Desktop.
FilamentPHP 3 Create Slug from Title
<?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