F
Filament3mo ago
Harold

Get selected rows in Wizrd form

Hello guys. Im buinding a wizard form and first step I wanna have a table and make it selectable so in step I can use all selected records as form input. How can I do this? What I have is:
public function table(Table $table): Table
{
return $table
->query(Broker::query())
->columns([
TextColumn::make('name')->label('Broker Name'),
])
->selectable()
// ->actions([
// Action::make('select')
// ->accessSelectedRecords()
// ->action(function (Broker $record, Collection $selectedRecords) {
// dump($selectedRecords);
// $this->brokers = $selectedRecords->pluck('id')->toArray();
// })->hidden(),
// ])
->filters([
])
->reorderable(false);
}
public function table(Table $table): Table
{
return $table
->query(Broker::query())
->columns([
TextColumn::make('name')->label('Broker Name'),
])
->selectable()
// ->actions([
// Action::make('select')
// ->accessSelectedRecords()
// ->action(function (Broker $record, Collection $selectedRecords) {
// dump($selectedRecords);
// $this->brokers = $selectedRecords->pluck('id')->toArray();
// })->hidden(),
// ])
->filters([
])
->reorderable(false);
}
Wizrd builder (important step):
Wizard\Step::make('Brokers')
->schema([
Forms\Components\Placeholder::make('brokers_table')
->label('Broker Selection')
->content(fn () => $this->table->render()), // Rendering the table within the form
])->afterValidation(function () {
dump('VALIDATION');
dump($this->table->getLivewire()->getSelectedTableRecords());
dump($this->brokers);
}),
Wizard\Step::make('Brokers')
->schema([
Forms\Components\Placeholder::make('brokers_table')
->label('Broker Selection')
->content(fn () => $this->table->render()), // Rendering the table within the form
])->afterValidation(function () {
dump('VALIDATION');
dump($this->table->getLivewire()->getSelectedTableRecords());
dump($this->brokers);
}),
1 Reply
Harold
HaroldOP3mo ago
$this->table->getLivewire()->getSelectedTableRecords() returns nothing even tho I have selected rows in my table
Want results from more Discord servers?
Add your server