Relationship

How can I customize the creation process of a relation manager? I'm trying to implement this https://github.com/filamentphp/filament/discussions/1514 But the methods (handleRecordCreation, mutateFormDataBeforeFill and handleRecordUpdate) are no longer fired!
GitHub
Translatable popup Relation managers Β· filamentphp filament Β· Discu...
Hello, I am working on solution, how to edit translatable fields in popup relation managers. I made a trait, that emit event, when you switch language on resource page. This trait is used in Edit p...
18 Replies
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
I guess i need to change it on the action but that makes it so i no longer can use 1 single trait which is kinda frustrating
Dennis Koch
Dennis Kochβ€’2y ago
You can use one custom action instead?!
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
yeah but then i basicly have to recode the whole thing becouse you don't have access to a bunch of things For example i think the owner record was not set yet in mutateRecordDataUsing which is a pain, becouse you can't access the language in that case i think
Dennis Koch
Dennis Kochβ€’2y ago
Not sure what's the isse sorry. Why do you need to re-code everything? What's the difference to using the mutate methods on the Action?
For example i think the owner record was not set yet in mutateRecordDataUsing
Should be fn ($livewire) => $livewire->ownerRecord
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
not recode everything, but it's also deffintly not a copy and paste let me check
Tables\Actions\EditAction::make()->mutateRecordDataUsing(function (array $data, TimeslotsRelationManager $manager) {
dd($manager->getOwnerRecord());
Tables\Actions\EditAction::make()->mutateRecordDataUsing(function (array $data, TimeslotsRelationManager $manager) {
dd($manager->getOwnerRecord());
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
Flare
Typed property Filament\Resources\RelationManagers\RelationManager::$ownerRecord must not be accessed before initialization - The error occurred at http://localhost:8000/admin/boats/173
Dennis Koch
Dennis Kochβ€’2y ago
Well, it's a different component that works differently, so it definitely needs some adjustments Not sure where you found $manager but it must be $livewire as in my example.
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
that works indeed, nice! not sure tbh πŸ˜‚ I think my ide suggested it
Dennis Koch
Dennis Kochβ€’2y ago
You cannot simply change var names, that Filament uses to inject data. What you did created a fresh, blank RM instance. Not the one you expected
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
ahh do you have any clue how i would get the current selected locale? the old way doesn't work anymore for some reason not really sure why
Dennis Koch
Dennis Kochβ€’2y ago
No sorry. Never worked with Translatable stuff πŸ™ˆ
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
there is a lot of magic happening and i can't find out where πŸ˜‚ so i looked at the code and the language selector is just a selectaction does this emit any events i would be ale to listen to?
Dan Harrin
Dan Harrinβ€’2y ago
livewire will allow you to hook into the update of that property
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
do you know what property that is, and how i can hook into that? most important is the first thing, second one i can propably figure out on my own
Dan Harrin
Dan Harrinβ€’2y ago
its the property with the same name of the action check the underlying code, its a simple wire:model
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
i'm relativly new to such complex livewire and with complex i mean a lot of classes/traits and whatnot
Dan Harrin
Dan Harrinβ€’2y ago
to be honest its very simple livewire once you understand that the only livewire component is the page
DanielvdSpoel
DanielvdSpoelOPβ€’2y ago
I figured it out! I created two new actions I'm wondering how to translate the table tough edit and create works, now the only thing left is the table does anyone have a clue how i would be able to do this maybe? maybe change the base query to only collect the selected language? πŸ€”
Want results from more Discord servers?
Add your server