Get value of field within an action

I have a field which uses a hintAction. This action opens a modal window and I want to prefill the field with the value of the component that triggers the action. I though of using fillForm but I don't see how to use e.g. a $get within that function. The documenation shows an example with $this->record but that doesn't work. This is the code:
->form([
RichEditor::make('job_description_original')
->disableAllToolbarButtons()
->label('Origineel')
->afterStateHydrated(function ($get) {
dd($get('job_description')); // returns null?
})
->disabled(),
->form([
RichEditor::make('job_description_original')
->disableAllToolbarButtons()
->label('Origineel')
->afterStateHydrated(function ($get) {
dd($get('job_description')); // returns null?
})
->disabled(),
I also tried to use the default function, which works, but I don't want the default to be the $record value, but the actual value inside the component:
->default(fn ($record) => $record->job_description), // works, but only with $record, not with $get
->default(fn ($record) => $record->job_description), // works, but only with $record, not with $get
What is the best practice in this case?
Solution:
Maybe this
->default(fn ($livewire) => $livewire->data['job_description'])
->default(fn ($livewire) => $livewire->data['job_description'])
...
Jump to solution
2 Replies
Solution
Patrick Boivin
Patrick Boivin16mo ago
Maybe this
->default(fn ($livewire) => $livewire->data['job_description'])
->default(fn ($livewire) => $livewire->data['job_description'])
Daniel Plomp
Daniel PlompOP16mo ago
Right. That indeed does the trick. Thanks!
Want results from more Discord servers?
Add your server