Panel - Are tags field dynamic options could be added manually by user?

Hello everyone :smiley:

I am working on a project with multiple tags fields to filtering projects. In order to avoid syntax mistakes I need to allow the user to enter manually a tag (achieve with accept: all), and in the meantime add this added tag to the dropdown list of options.

Is this possible ?
What is a good starting point ?

Here is my little piece of code ::

projectTags: 
        label: my project tag
        type: tags
        options:
          - i need those to be added manually by the user

Thanks for your help :slight_smile:

++
M

I somehow don’t understand what you want to achieve. The field you are showing here doesn’t have accept: all?

Are you referring to the same field in other pages? Then you would query the siblings, so that once the user has added a tag manually on one page, it is available as suggestion in sibling pages.

Thanks for your reply :wink:
Yes you’re right, but it seems like accept default state is ‘all’

No the field is only present on this page, and I would like to add each new added tag to the dropdown list, is this clearer ?

Sorry, no, this is even more confusing. Why would you want to fill an option list for a field only present on a single page if the user adds the option manually?

Can you maybe explain the purpose of this exercise? Is this to predefine some options that can then be used somewhere else?

I’m sorry to be confusing.
It’s a projects page, each project contains tags, that let me filter the projects by tag. Because tags are case sensitive, and because the user could make mistakes entering tags, I would like each newtag added to be present in the dropdown list to avoid write it a second time in order to prevent mistakes (like add a extra “s” or forgotting a letter.
In this first screenshot, you can see the “Tags medium” field with the dropdown list that contains a list of predefined tags setup with “options” in the page (project.yml) blueprints.


In this second screenshot, i added a “newtag” manually. What I want is, this newtag to be available in the dropdown list for all the other new created page (project), so that the user can choose it without need to write it a second time.

I hope it’s clearer now :slight_smile:

Thanks for being patient,
++
M

Ok, so not a single page.

To mix some pre-defined options with the values entered in siblings pages, you can create a custom method in a page model, e.g. getOptions, that merges an array of fixed options with the values plucked from siblings pages:

          tags:
            type: tags
            options:
              type: query
              query: page.getOptions()
	public function getOptions()
	{
		$optionsFromSiblings = parent::siblings()->pluck('tags', ',', true);

		return array_merge($optionsFromSiblings, ['a', 'b', 'c']);
	}