Problems using Repeater in an action

Hello, I'm trying to implement a Repeater with a relationship, the point is that I want to do some validations with the data that is entered in the Repeater before they are saved, my problem is that when I use the mutateRelationshipDataBeforeCreateUsing, it doesn't return the entire array of data that is inside the Repeater, has anyone had something similar happen to them, THANKS Action::make('Regisrar Tramite') ->icon('heroicon-o-clipboard-document-check') ->form([ Section::make() ->columns(2) ->schema([ ...... ]), Repeater::make('tramites') ->relationship() ->schema([ ........................ ])
->mutateRelationshipDataBeforeCreateUsing(function ($record, $data) { dd($record, $data); }) ->columns(3) ->addActionLabel('Agregar Trámite') ->collapsible() ]) I attach the code used for the action, and the test image that only returns the first batch of data from the repeat, and not like this or others
No description
1 Reply
Will 🇬🇹
Will 🇬🇹2mo ago
Since your Repeater is tied to a ->relationship() it gets saved to the DB per item in your repeater. So it makes sense to only return the information of your current item. If you need to get information OUTSIDE your repeater you need to access it by injecting Get $get in your ->mutateRelationshipDataBeforeCreateUsing(function ($record, $data) { Like this
->mutateRelationshipDataBeforeCreateUsing(function ($record, $data, Get $get) {
// ../ <== tells filament to go UP once from the repeater
$otherField = $get('../client_id');
})
->mutateRelationshipDataBeforeCreateUsing(function ($record, $data, Get $get) {
// ../ <== tells filament to go UP once from the repeater
$otherField = $get('../client_id');
})

Did you find this page helpful?