Filament is saving relationship only on edit (update) pages but not on create.

Its the first time it happened to me and im not sure what im doing wrong. I have a BriefResource.php file which has 2 components which are relationships. one of them is a hasMany() relationship and the other one is many to many. I tried to copy and format the code here but it attached it as a paste file(?), never saw that in discord. Anyway, both of these fields are not saving on the create page but work just fine when i edit a brief and update it. What could be the reason? The is no special manipulation in CreateBrief.php whatsoever.
1 Reply
prowler
prowlerOP6mo ago
All the relationships are defined correctly on the models levels * i tried using ->saveRelationshipsUsing on them with no help... ok, i spotted something interesting.. not sure if its a bug in filament/livewire or just a bad architecture by myself. my whole $form has a disabled function attached to it conditionally in this way -
return $form
->schema([ ... ])
->disabled(fn (?Brief $record): bool => $record?->status === BriefStatusEnum::Processing->value);
return $form
->schema([ ... ])
->disabled(fn (?Brief $record): bool => $record?->status === BriefStatusEnum::Processing->value);
Once the form is disabled - all its relationships aren't being saved. Once I remove this disabled condition - it all works just fine.
Want results from more Discord servers?
Add your server