Problem with rows that have null values
If one field in a row is filled and the second field is null, then the value of null in the second field is wrapped in an array. In the case of TextColumn it does not cause problems, but when using TextInputColumn the error "Array to string conversion" is displayed.
1 Reply
Table definition
public function table(Table $table): Table
{
return $table
->query((new Query())->get())
->filters([
(new Filters())->getStructureTrainerGroupFilter()
])
->columns([
Tables\Columns\TextColumn::make('user.full_name')->label('Фамилия, Имя, Отчество')->searchable(),
Tables\Columns\SelectColumn::make('kyudan.place')
->options(Kyudans::LIST)
->label('Стилевая квалификация')
->updateStateUsing(function (string $state, Sportsman $record): ?string {
$this->kyudans[$record->id]['number'] = $state;
return $state;
}),
Tables\Columns\TextInputColumn::make('kyudan.certificate_number')
->label('Номер сертификата')
])
->recordClasses(function (Sportsman $record) {
$isKyudanExists = $record->kyudan()->exists();
if ($isKyudanExists)
{
return 'bg-yellow-100';
}
return null;
});
}
public function table(Table $table): Table
{
return $table
->query((new Query())->get())
->filters([
(new Filters())->getStructureTrainerGroupFilter()
])
->columns([
Tables\Columns\TextColumn::make('user.full_name')->label('Фамилия, Имя, Отчество')->searchable(),
Tables\Columns\SelectColumn::make('kyudan.place')
->options(Kyudans::LIST)
->label('Стилевая квалификация')
->updateStateUsing(function (string $state, Sportsman $record): ?string {
$this->kyudans[$record->id]['number'] = $state;
return $state;
}),
Tables\Columns\TextInputColumn::make('kyudan.certificate_number')
->label('Номер сертификата')
])
->recordClasses(function (Sportsman $record) {
$isKyudanExists = $record->kyudan()->exists();
if ($isKyudanExists)
{
return 'bg-yellow-100';
}
return null;
});
}