Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

can’t get @data-options function call to work

Started by Anna 8 hours ago · 0 replies · 15 views
8 hours ago

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:

YAML
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!

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Anna, 1 week ago
5 166 4 days ago
Forms & Blueprints · by TomW, 1 month ago
3 363 1 month ago
Forms & Blueprints · by Japhy, 2 months ago
2 583 2 months ago
Forms & Blueprints · by FrViPofm, 2 months ago
5 612 2 months ago
Forms & Blueprints · by Ton Haarmans, 6 years ago
13 2611 9 months ago