F
Filament10mo ago
Lucky0

How to autofill recordId on TextInput in AttachAction

As the title suggests, undefined array key "recordId."
AttachAction::make()
->form(function () {
return [
TextInput::make('recordId'),
SelectTree::make('parent_id')
->relationship('parent', 'name', 'parent_id)
];
})
AttachAction::make()
->form(function () {
return [
TextInput::make('recordId'),
SelectTree::make('parent_id')
->relationship('parent', 'name', 'parent_id)
];
})
2 Replies
Vp
Vp10mo ago
I am not sure about "attach action" but I think all action will be same, so here's the link https://filamentphp.com/docs/3.x/actions/modals#filling-the-form-with-existing-data
Lucky0
Lucky0OP10mo ago
Thank you. I found a solution for that.
use Livewire\Component as Livewire;

AttachAction::make()
->form(function () {
return [
TextInput::make('recordId')
->default(fn(Livewire $livewire) => $livewire->ownerRecord->id))
->readOnly()
->dehydrated()
->required(),
SelectTree::make('parent_id')
->relationship('parent', 'name', 'parent_id)
];
})
use Livewire\Component as Livewire;

AttachAction::make()
->form(function () {
return [
TextInput::make('recordId')
->default(fn(Livewire $livewire) => $livewire->ownerRecord->id))
->readOnly()
->dehydrated()
->required(),
SelectTree::make('parent_id')
->relationship('parent', 'name', 'parent_id)
];
})
But now I'm facing another problem where every time I attach a new category using SelectTree it only select the parent_id.
Want results from more Discord servers?
Add your server