Closed panda4man closed 1 year ago
I've taken a look at how this works when using the Entries fieldtype on an entry. This is what $values
looks like:
There's no context about the value of the other fields.
Since this isn't specifically a Runway issue (context not being passed to the query scope), but rather something that's not there in Statamic core, it might be worth opening an issue there instead.
That's what I figured. Thanks, sir!
Description
I'm trying to run a query scope on an entries field type where that scope uses contextual data to do the filtering. That contextual data needs to be such that I'm able to run a query based on this data to fetch further data to subsequently use in the scope.
More specifically, I have a Runway collection called Products. This collection has two fields in particular that are relevant to this issue:
On any given product details page in the CP, I want to be able to filter the available types via a query scope, using the selected value of Attribute Group to do this filtering.
I have a query scope called ProductAttributeTypeFilter which extends the base Statamic
Statamic\Query\Scopes\Scope
class.The
apply($query, $values)
method receives an array of request-contextual data which I was hoping would contain information relevant to the base Runway parent product the page is on. It does not. Here's what that payload looks like:In the context of this issue, this
$values
array comes from the following method:Statamic\Fieldtypes\Entries::getIndexQuery()
->applyIndexQueryScopes($query, $request->all())
Based on what I can see,
$request->all()
is what is being passed down to the query scope as its second parameter$values
.I believe this endpoint is called by a Vue component, but at this point I'm wondering if I am going against the grain of the expected functionality of CP query scopes & filters.
Steps to reproduce
$values
Environment
Environment Application Name: Statamic Peak Laravel Version: 10.18.0 PHP Version: 8.2.7 Composer Version: 2.5.8 Environment: local Debug Mode: ENABLED URL: alpine-power-statamic-2023.test Maintenance Mode: OFF
Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED
Drivers Broadcasting: log Cache: statamic Database: mysql Logs: daily Mail: smtp Queue: redis Session: file
Statamic Data Importer Version: 0.0.1
Statamic Kentico Migrator Version: 0.0.1
Statamic Addons: 6 Antlers: runtime Stache Watcher: Enabled Static Caching: Disabled Version: 4.21.0 PRO
Statamic Addons doublethreedigital/runway: 5.2.0 fahlgrendigital/tools-for-statamic: 0.7 studio1902/statamic-peak-browser-appearance: 2.0 studio1902/statamic-peak-commands: 2.3.2 studio1902/statamic-peak-seo: 2.6.2 studio1902/statamic-peak-tools: 3.2