F
Filament7mo ago
bogus

Editable TextInputColumn with HasMany

Hello, Perhaps I want too much from filamentphp ... but anyway .. I have HasMany relaation
public function commissions(): HasMany
{
return $this->hasMany(Commission::class);
}
public function commissions(): HasMany
{
return $this->hasMany(Commission::class);
}
and a simple table like this:
public static function table(Table $table): Table
{
$columns = [
Tables\Columns\TextColumn::make('id')->searchable(),
Tables\Columns\TextColumn::make('commissions.value'),
];

foreach (range(0,3) as $id){
$columns[] = Tables\Columns\TextInputColumn::make('commissions.'.$id.'.value')->label('commissions.'.$id.'.value');
}

return $table
->columns( $columns);
}
public static function table(Table $table): Table
{
$columns = [
Tables\Columns\TextColumn::make('id')->searchable(),
Tables\Columns\TextColumn::make('commissions.value'),
];

foreach (range(0,3) as $id){
$columns[] = Tables\Columns\TextInputColumn::make('commissions.'.$id.'.value')->label('commissions.'.$id.'.value');
}

return $table
->columns( $columns);
}
Which displays the data correctly, but does not allow me to save .. Filament tries to execute the following SQL request:
update `my_table_name` set `commissions` = {"1":{"value":"222"}}, `cities`.`updated_at` = 2024-05-26 19:24:13 where `id` = 1
update `my_table_name` set `commissions` = {"1":{"value":"222"}}, `cities`.`updated_at` = 2024-05-26 19:24:13 where `id` = 1
but this is wrong How can I make it so that the data can be saved?
Am I missing something or filament don't allow use TextInputColumn with HasMany relation ? Thanks
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server