Edit not working

I am going through a tutorial and have watched the same video a few times to see if I had incorrect syntax on my form, but to me it looked ok. But when I hit 'edit' and then click save changes I get an error that the value already exists. This is happening on each of the forms I created.
public static function form(Form $form): Form
{
return $form
->schema([
Group::make()
->schema([
Section::make()
->schema([
TextInput::make('name')
->required()
->live(onBlur:true)
->unique()
->afterStateUpdated(function(string $operation, $state, Forms\Set $set){
if($operation!=='create'){
return;
}
$set('slug', Str::slug($state));

})

])
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Group::make()
->schema([
Section::make()
->schema([
TextInput::make('name')
->required()
->live(onBlur:true)
->unique()
->afterStateUpdated(function(string $operation, $state, Forms\Set $set){
if($operation!=='create'){
return;
}
$set('slug', Str::slug($state));

})

])
]);
}
Solution:
Because you have ->unique() validation, you have to provide like ->unique(ignoreRecord: true)
Jump to solution
3 Replies
Solution
Vp
Vp15mo ago
Because you have ->unique() validation, you have to provide like ->unique(ignoreRecord: true)
einnlleinhatt_
einnlleinhatt_OP15mo ago
I see, was thinking about that but in the tutorial it's only unique doesn't have the ignoreRecord. I'm assuming they did it on off cam. Thank you
Want results from more Discord servers?
Add your server