field value disapear during my slug generation
This is my field code:
TextInput::make('name')
->required()
->label('Nom de la chambre')
->live(onBlur: true)
->afterStateUpdated(fn(?string $state, Set $set) => $set('slug', SlugService::createSlug(Lodging::class, 'slug', $state ?? '', ['unique' => true])))
Like the video show, during the time during the slug is generated, if the user continue to fill the form, it will remove all. Not a good experience for the user. How can I ovoid this ?
Like the video show, during the time during the slug is generated, if the user continue to fill the form, it will remove all. Not a good experience for the user. How can I ovoid this ?
7 Replies
Hello ! No one ?
Add a loading indicator within the form?
https://filamentphp.com/docs/3.x/support/blade-components/loading-indicator
Thx for the answer but not the best solution. I can't just specify the input to updat and not update the other ?
You have to disable the inputs based on loading. Most of the time it's quick enough to not notice / delay of the changes
Hello,
You may want to test run this: https://filamentphp.com/docs/3.x/forms/advanced#debouncing-reactive-fields
Thank's for your answer. 😄
Yes, maybe it's because it's on myu local ... ^^^'
Thank's for the answer but I don't understand how that can help me 😄
You use
->live(onBlur: true)
which means that your slug
field is populated only when you leave your name
field.
I guess you choose this instead of just ->live()
to avoid many requests occurring every time a simple character is typed.
But it appears to be too slow: so try and use debouncing (my link) in order to find a "in-between" solution.