First off, what I would ultimately like to achieve is several optgroups in a frontend form select field, consisting of four parent pages and their respective children as options.
I think I need to write my own function for that (because of the optgroups), but to get me started I copied the example from the docs:
form:
fields:
route:
type: select
label: Parent
classes: fancy
data-default@: '\Grav\Plugin\Admin::route'
data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes'
options:
'/': '- Root -'
And this already returns nothing, sadly. I tried some other methods I found in the PHP reference for Pages, but the only one that returns anything is \Grav\Common\Page\Pages::types – that returns the types alright. But all or children or routes don’t return anything, and neither can I see any errors or other hints.
I don’t know how to debug this, or more importantly, I don’t know how to create a function in my theme that returns something. I also don’t know if I need to register a custom data provider for that like the docs suggest, so I wanted to try the example first, and that is already tripping me up.
Suggestions and thoughts much appreciated!