How to use custom column inside ViewAction

i created a custom column which im using in my table component. https://filamentphp.com/docs/2.x/tables/columns/custom#view-column In the docs, i understood that i can also use it inside a view action:
ViewAction::make()
->recordTitle(__('game'))
->label('')
->color('primary')
->tooltip(__('See game details'))
->modalHeading(__('See game'))
->mountUsing(function (\Filament\Forms\ComponentContainer $form, Game $record) {
$record->load('createdBy');
$record->load('winner');

$form->fill($record->toArray());
})
->form([
Grid::make(4)
->schema([
ViewColumn::make('result')
->view('tables.columns.game-result-column')
->translateLabel()
,
...
ViewAction::make()
->recordTitle(__('game'))
->label('')
->color('primary')
->tooltip(__('See game details'))
->modalHeading(__('See game'))
->mountUsing(function (\Filament\Forms\ComponentContainer $form, Game $record) {
$record->load('createdBy');
$record->load('winner');

$form->fill($record->toArray());
})
->form([
Grid::make(4)
->schema([
ViewColumn::make('result')
->view('tables.columns.game-result-column')
->translateLabel()
,
...
but im getting:
Filament\Forms\ComponentContainer::Filament\Forms\Concerns\{closure}(): Argument #1 ($component) must be of type Filament\Forms\Components\Component, Filament\Tables\Columns\ViewColumn given

in the line where i fill the form: $form->fill($record->toArray());
Filament\Forms\ComponentContainer::Filament\Forms\Concerns\{closure}(): Argument #1 ($component) must be of type Filament\Forms\Components\Component, Filament\Tables\Columns\ViewColumn given

in the line where i fill the form: $form->fill($record->toArray());
what should i do?
5 Replies
ericmp
ericmpOP2y ago
seems i understood it wrong hmm. but anyways is there somehow to do what i try to achieve? im diggin in the docs to see if i can find it if someone replies, id appreciate an @ so i get notified, thanks (:
Dan Harrin
Dan Harrin2y ago
@ericmp columns are not form fields they are separate objects
ericmp
ericmpOP2y ago
thanks yeah hmm. so is there any way to put like a custom component inside a view modal?
Dan Harrin
Dan Harrin2y ago
yes, a form component View::make() or ViewField::make() depending if you want to store state or not or if this is the only thing in the entire action form, you can use modalContent() instead to render a view instead of a form
ericmp
ericmpOP2y ago
i see. ill try that. thanks again!
Want results from more Discord servers?
Add your server