In the example of title and slug inputs, which whenever something is written in title, will be written in slug.
But I want to have a checkbox that determines whether it should automatically write(convert) to slug input or not.
TextInput::make('title')
->reactive()
->afterStateUpdated(static::fillSlug(...))
->required(),
TextInput::make('slug')
->disabled(fn (callable $get) => $get('fill slug based on title'))
->required(),
Checkbox::make('fill slug based on title')
->default(true)
->inline(false)
->reactive()
->afterStateUpdated(static::fillSlug(...))
->dehydrated(false),
fillSlug
sets slug if checkbox is checked
The problem:
It works on create page, but on edit page checkbox is not checked. How can I check the checkbox?
I've tried ->extraAttributes(['checked' => 'true'])
but that doesn't works.