Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'default' and 'options' for taxonomy field #1364

Merged
merged 1 commit into from Mar 9, 2018

Conversation

pshe94
Copy link
Contributor

@pshe94 pshe94 commented Mar 3, 2018

With this patch user can override in blueprint the taxonomy field to add custom taxonomy values in default and options attributes.
There is only one catch - when overriding default taxonomy field, with both default and options attributes, you need to add validation attribute with type: commalist, as shown in example below. Otherwise, after first save Grav will throw an error at top of the page Array to string conversion, and page won't be saved. But after second try, it will be successful. I haven't found why this happens, but adding validation fixes it. I'm guessing that it might be related to #1024.

taxonomies:
  fields:
    header.taxonomy:
      default:
        category: ['blog','page']
        tag: ['test']
      options:
        category: ['grav']
      validate:
        type: commalist

@pshe94 pshe94 closed this Mar 3, 2018
@pshe94 pshe94 reopened this Mar 3, 2018
@rhukster rhukster merged commit 963ca2f into getgrav:develop Mar 9, 2018
@rhukster
Copy link
Member

rhukster commented Mar 9, 2018

Nice improvement 👍

@KennethJoris
Copy link

KennethJoris commented Mar 19, 2018

Just what i was looking for GREAT :)
Do add this info to the documentation please

I do see an issue with the other options for this field that don't work anymore (i didn't use the default part as discribed above):

  • multiple: false
  • validate.required: true

header.taxonomy: type: taxonomy label: 'a label.' multiple: false options: category: ['blog','events','people'] validate: type: commalist required: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants