F
Filament2y ago
Finn

Access relationship data in mutateFormDataBeforeCreate

I have created a Repeater that goes into another model 'invoice_rows' like this: Forms\Components\Repeater::make('invoice_rows')->label('Factuur regels')->relationship('row') with the ->relationship('row') function. But in my resource Create file (CreateAdminInvoices.php) I use protected function mutateFormDataBeforeCreate(array $data) and I want to access the form data of the relationship there as well, but that's not included in the $data variable. How do I make that accessible there as well?
4 Replies
Finn
FinnOP2y ago
Now I found a way of accessing the data if I do dd($this->data) I can see the full form data, is that a valid way?
Dennis Koch
Dennis Koch2y ago
Yeah that's fine. It's not included in the state, as it saves directly to the DB. There is also a mutateRelationshipDataBeforeCreate (or similar naming)
Dan Harrin
Dan Harrin2y ago
@boomstam i would advise against reading the data directly from the form the method that dennis suggests is the safest way
Finn
FinnOP2y ago
Thanks, I will implement that!
Want results from more Discord servers?
Add your server