Is there a better way to set the default value in RelationManager?
I currently have a itemsRelationManager where you can see all the items from 1 category.
The problem i have is i want to set the default value for category_id when you create a Item in the category.
Is there a better way to get the category id?
Code:
Solution:Jump to solution
yeah this:
```php
->default(function (RelationManager $livewire) {
return $livewire->getOwnerRecord()->getAttribute('id');
})...
7 Replies
I'm using this way myself as well, something wrong with the result you're getting?
No but i am just getting a property accessed magic method in my editor error @RamonVveghel i found the fix for it.
ooh, ->getOwnerRecord() probably?
Solution
yeah this:
which is what I'm doing
yeah. nice!
thanks for your input π
You can also turn in into an array for multiple values
Np!