Nuck Figgers
Nuck Figgers
FFilament
Created by Nuck Figgers on 1/30/2024 in #❓┊help
Set Action record for later use
Hi. Is it possible to set record in fillForm() method that can I later use in action()?
...
->fillForm(function (Order $order, array $arguments, Action $action): array {
if (array_key_exists('order', $arguments)) {
$order = Order::with(['relations'])->find($arguments['order']['id']);

$action->record($order); // set record
}

# dd($action->getRecord()); // record is set properly
return $this->fillOrder($order->toArray());
})
->form($this->orderForm())
->action(function (array $data, Order $order, Action $action): void {
dd($action->getRecord()); // returns null
...
->fillForm(function (Order $order, array $arguments, Action $action): array {
if (array_key_exists('order', $arguments)) {
$order = Order::with(['relations'])->find($arguments['order']['id']);

$action->record($order); // set record
}

# dd($action->getRecord()); // record is set properly
return $this->fillOrder($order->toArray());
})
->form($this->orderForm())
->action(function (array $data, Order $order, Action $action): void {
dd($action->getRecord()); // returns null
2 replies
FFilament
Created by Nuck Figgers on 1/24/2024 in #❓┊help
Infolist component key/name issue while testing
Hi. I'm currently writing tests for infolist hint actions and I have problem accessing nested components. This is my infolist schema:
$infolist->schema([
Tabs::make('tabs')
->key('tabs')
->tabs([
Tabs\Tab::make('notes')
->key('notes')
->schema([
TextEntry::make('internal_note')
->key('internal_note')
->hintAction($this->editInternalNoteAction())
...
])
])
])


// Test:
livewire(OrderDetails::class, ['order' => $this->order])
->callInfolistAction('internal_note', 'editInternalNote', data: ['content' => 'test']);
$infolist->schema([
Tabs::make('tabs')
->key('tabs')
->tabs([
Tabs\Tab::make('notes')
->key('notes')
->schema([
TextEntry::make('internal_note')
->key('internal_note')
->hintAction($this->editInternalNoteAction())
...
])
])
])


// Test:
livewire(OrderDetails::class, ['order' => $this->order])
->callInfolistAction('internal_note', 'editInternalNote', data: ['content' => 'test']);
The only component I can access is the one on the first level which is just tabs component. I've tried dot notation (tabs.notes.internal_note) but still noting. Any idea how can I test these actions? My Filament version is 3.2
1 replies