Query language as option for a select field doesn't work

Hi,

The following doesn’t work. Am I missing something?

author:
  label: Author
  options:
    - "{{ site.title }}"
    - User
  required: true
  type: select

You can’t use query language for an option. You could provide your options via the API options. Then you are free to set you options as you like, for just those two options, that will be a bit of a pain, though.

However, why don’t you do it like this:

author:
  label: Author
  options:
    - sitetitle: Site Title
    - user: User
  required: true
  type: select

And then check the value in your template, and return the title if title etc.

if ($page->author()->value() === 'sitetitle') {
  echo $site->title();
}

Thanks, but in this case I don’t know the site title. It’s a setting within the panel where the default author of the blog post is the “site” but you can change to user where you’ll pick one. But I will think of another solution :slight_smile:

But if you can query the site title in your blueprint with this - "{{ site.title }}", you might as well get it in your template, no matter if that is something static or dynamic. I don’t see any difference here, but maybe I’m missing something.

The only thing in my case that would have made sense was to have - "{{ site.title }} as an option for the select field. But I found another UX solution that is good enough!