FilamentF
Filamentβ€’3y ago
d3v1anX

Two TextColumns from same field

Hey guys,
I tried to add two TextColumns from the same date field. One with only date, the other with the time.

Looks like this:
  Tables\Columns\TextColumn::make('start')
      ->label('Start date (UTC)')
      ->date()
      ->sortable()
      ->searchable(),
  Tables\Columns\TextColumn::make('start')
      ->label('Start time (UTC)')
      ->time()
      ->sortable(),


there only the second field will be displayed.

I tried to change the name and use state for displaying data - this will display both fields, but then it is not sortable / searchable, because the sort field is used from "make".

Tables\Columns\TextColumn::make('start date')
    ->state(fn (Model $record) => $record->start)
    ->label('Start date (UTC)')
    ->date()
    ->sortable()
    ->searchable(),
Tables\Columns\TextColumn::make('start')
    ->label('Start time (UTC)')
    ->time()
    ->sortable(),

Is my approach to display two fields of one column correct? Or am I missing something? πŸ™‚

Thank you very much!
Was this page helpful?