Merge a hidden- and a tag-Field to a select-Field

I have a page on which I have stored predefined distances in an options tab with the help of a hidden field:

settingspacesdefault:
        label: Standard
        type: hidden
        default: 2xs, xs, sm, default, lg, xl, 2xl, 3xl

Then I have a sep. field with which I can set my own values distances:

settingspacescustom:
        label: margin, padding, Spaltenabstand
        type: tags
        icon: collapse

In a new field - on the same page - I want to combine the values from settingspacesdefault and settingspacescustom (+ ???) in a select box and output them:

label: 'Spaces'
type: select
options: query
query:
  fetch: page.settingspacesdefault.split + ???

How can I do this?

Create a page method that merges the two arrays, then use that in your query.

Thank you texnixe.
Hmm… so I can build up a single query (for a field) and display it in the select box.
I’m not that experienced with PageMethod and merging queries yet. Could you give me some help here?

          spaces:
            label: 'Spaces'
            type: select
            options: query
            query:
              fetch: page.mergeFieldOptions

In your model (or alternatively as a custom field method):

class NotePage extends Page // adapt model name to fit your page type
{
	public function mergeFieldOptions()
	{
		return array_unique(array_merge($this->settingspacesdefault()->split(), $this->settingspacescustom()->split()));
	}
}

Note that this will not include options from thesettingspacescustom field that are not saved yet.

Thank you…

This works for me:

class BlogpostPage extends Page
{
    public function spaces()
    {
        $defaultSpaces = $this->settingspacesdefault()->split();
        $customSpaces = $this->settingspacescustom()->split();
        return array_merge($defaultSpaces, $customSpaces);
    }
}
label: 'Spaces'
type: select
options: query
query:
  fetch: page.spaces

This will show duplicate entries, if you don’t use array_unique…

:+1:t2: Thank you