Show related entity's details in an RelationManager edit modal
I have 3 entities, Customer, Product and Wishlist, with the latter having both product_id and customer_id in it
I'm trying to show a customer's wishlist in its details page, which works fine inside the RelationManager table by just using product.title and product.price, but when I go edit this relation those 2 fields are emtpy (while other fields that are directly on the wishlist table are shown fine)
What am I missing here? Why does it work in the table but not in the form?
Solution:Jump to solution
I managed to get it working by doing this:
```Forms\Components\TextInput::make('product.lowest_price')
->loadStateFromRelationshipsUsing(function($record, $component) {
$component->state($record->product->lowest_price);
})...
3 Replies
this also happens in non-relationmanager edit/view pages as well, apparently it's not loading the relation correctly?
Ok, I could fix showing the product title by using
select::relationship
, which is fine, but what about the price, since that isn't a related item but rather a property of the product?Can you share the code of your relation manager? Specifically the table and custom action.
Solution
I managed to get it working by doing this: