processwire / processwire-requests

ProcessWire feature requests.
39 stars 0 forks source link

Add $pages->findRaw() option to return "single" Page Reference field values directly #458

Open Toutouwai opened 2 years ago

Toutouwai commented 2 years ago

Short description of the enhancement

Currently when using $pages->findRaw() to get a subfield value of a Page Reference field the returned value is always an array regardless of whether the derefAsPage setting for the field is "single page" or "multiple pages".

2022-09-19_144027

But in the situation shown above it would be preferable in a lot of cases if the returned value for colour.title was the string "Orange" rather than an array containing a single item. Often when I use findRaw() I have to foreach the result in order to get rid of these nested arrays and get the desired single value and it would be great if there was an option that avoided the need to do this.