Update value
When I update the registration field it does not update the owner field, it returns a blank value
Forms\Components\Select::make('vehiculos_id')->required()->label('Matricula')
->searchable()
->relationship('vehiculos','matricula')
->afterStateUpdated(function (Set $set) {
$set('partes.vehiculos_id', null);
})
->preload()->live(), Forms\Components\TextInput::make('partes.vehiculos_id')->label('Propietario') ->formatStateUsing(function ($state, Parte $partes) { if (!empty($partes->vehiculos->clientes)) { return $partes->vehiculos->clientes->apellidos . ', ' . $partes->vehiculos->clientes->nombre; } else { return null; } }) ->disabled()->live(),
->preload()->live(), Forms\Components\TextInput::make('partes.vehiculos_id')->label('Propietario') ->formatStateUsing(function ($state, Parte $partes) { if (!empty($partes->vehiculos->clientes)) { return $partes->vehiculos->clientes->apellidos . ', ' . $partes->vehiculos->clientes->nombre; } else { return null; } }) ->disabled()->live(),
8 Replies
I think
formatStateUsing()
only runs on initial load.Correct and seo works perfectly, what I don't give is implementing a get to collect the values of the previous field when it is updated
@HeyWeb I think you're doing something really in the wrong direction, cause you're having a text input for partes.vehiculos_id but trying to fill it with nombre of clientes, so it isn't actually the ID field?
I would probably re-think your approach in general, but too little information to advise on that
From the license plate I look for which vehicle it belongs to and by the vehicle_id I look in the table to which client it belongs to, it is a purely informative field
Parts (license)->vehicle_id->customer_id
The problem is that when updating the registration field, the customer field remains blank, because it does not collect the set that is sent to it or it was sent incorrectly.
But you're setting it to null yourself:
Shouldn't it set the value exactly here, instead of null?
Here's a code example of erpsaas open-source project:
https://github.com/andrewdwallo/erpsaas/blob/ec56e8ece6000fbe3faeddf59a7d81a44e727dd5/app/Filament/Company/Resources/Banking/AccountResource.php#L107C41-L132C58
GitHub
erpsaas/app/Filament/Company/Resources/Banking/AccountResource.php ...
A Laravel and Filament-powered accounting platform, crafting a modern and automated solution for financial management. - andrewdwallo/erpsaas
Thanks