Jump to content

How to enable allowUserTags to give a 'tags' field that content editors can use to select existing and create new tags?


artfulrobot
 Share

Recommended Posts

I added a Select Options field called tags. On the "details" settings tab I chose TextTags (Multiple sortable values)

When I edit a page with this field on, and type a new tag name, e.g. 'new', it says it's going to Add new. I press <SPACE> and it renders the `new` as a tag. Then I hit Save and it compain: Removed invalid tag value: new.

image.png.26e6920b5985ac12ca201a1e8279e558.png

 

 

 

 

 

The UI looks like it's ok for me to add a tag, but hitting Save says otherwise.

I see from the API docs:

https://processwire.com/api/ref/inputfield-text-tags/

that there's an "allowUserTags" setting, but that doesn't seem to be exposed in the edit field UI? Also I observed that if I add values on for the tags field then I'm only allowed to select those, and not allowed to add new tags.

Any help gratefully received. 

Link to comment
Share on other sites

Check out the blog post that introduced InputfieldTextTags: https://processwire.com/blog/posts/pw-3.0.177/#using-with-options-fields

Quote

A page-editing user can't add new selectable options to an Options field, so the ability to add new items is also not a consideration.

If you use a Page Reference field for your tags then you can add new tags via the inputfield if the field settings are configured to allow it. From the blog post:

Quote

If your Page field is for input in the page editor, and its settings have the "Allow new pages to be created from field?" option selected, then TextTags will also allow the user to type in new options and they will be created as new pages when saved.

 

  • Like 2
Link to comment
Share on other sites

Using a Page Reference field with a Text Tags input as explained in the blog post mentioned by @Robin S works. Here's the steps I had to take:

  1. Create a new Template (without template file, but might want to add one later) called tag
  2. Create a new Template (without template file) called tags. There are a few settings to note here:
    • Family » Allowed templates for children: set to 'tag'
    • Family » children are sorted by: Name.
  3. Create a new Page called Tags that uses the tags template and put it under Admin in the tree.
    • Settings: Unpublished, Hidden, Locked
    • Each tag will be a page under this.
  4. Creae a new Field using the field type Page Reference. I named mine Tags
    • Details » Page field value type: Multiple pages
    • Input » Input field type: Text Tags
    • Input » Selectable pages: choose Parent: Tags (the page created above), Template: tag (the first template we created for individual tags).
    • Input » Label field: title (default)
    • Allow new pages to be created from this field: ✔
  5. Add the tags field to the page template(s) you want to use it with.
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...