Fill form from within resource

which function does filament use to fill it's form on a resource? I wanna fill the form with model data without actually attaching a model to the form, kinda like cloning a model if that makes sense I see that the fillForm method is available on the EditRecord and the ViewRecord class. I want to use it from the resource, e.g. when a select is changed, refill the data depending on the select entry. I know I could use Closure customization but that would lead to a lot of work as I want to implement this functionality across different models with different attributes.
1 Reply
Quadrubo
QuadruboOP2y ago
Essentially I want to find an easier way than doing this abomination on every resource.
...
$set('manufacturer_id', $record->manufacturer_id);
$set('layout_id', $record->layout_id);
$set('location', json_decode($record->location, true));

$record->parks->each(function ($park, $parkKey) use ($set) {
$set('pivotParks.'.$parkKey.'.park_id', $park->id);
$set('pivotParks.'.$parkKey.'.from', $park->pivot->from);
$set('pivotParks.'.$parkKey.'.to', $park->pivot->to);
});
...
...
$set('manufacturer_id', $record->manufacturer_id);
$set('layout_id', $record->layout_id);
$set('location', json_decode($record->location, true));

$record->parks->each(function ($park, $parkKey) use ($set) {
$set('pivotParks.'.$parkKey.'.park_id', $park->id);
$set('pivotParks.'.$parkKey.'.from', $park->pivot->from);
$set('pivotParks.'.$parkKey.'.to', $park->pivot->to);
});
...
Want results from more Discord servers?
Add your server