ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Computed fields inside a Grid?

Open duncanmcclean opened this issue 3 years ago • 1 comments
trafficstars

Thanks so much for the new Computed Fields feature - I can think of a dozen use cases for it across my different sites.

Currently, I have something similar-ish using custom hidden fieldtypes in one of my addons which I'm aiming to replace with this feature.

However, some of them are computed fields inside a Grid field.... I have a Grid field called 'Line Items' and inside that I have the product, price, etc. If I wanted to make two new computed fields on each line item (like tax_price or raw_price), I don't currently see a way of doing it...

I've tried these two options, neither work.

Collection::computed('orders', 'line_items.raw_price.', function ($entry, $value) {
    return 'something here';
});

Collection::computed('orders', 'line_items.*.raw_price.', function ($entry, $value) {
    return 'something here';
});

duncanmcclean avatar Oct 21 '22 21:10 duncanmcclean

It's a top level data feature at the moment, not specific to any fieldtype.

jesseleite avatar Oct 22 '22 13:10 jesseleite