xiaohutai / jsonapi

[Bolt Extension] JSON API for Bolt CMS
https://market.bolt.cm/view/bolt/jsonapi
MIT License
55 stars 18 forks source link

Error when making slug field hidden #62

Closed rainpoiss closed 7 years ago

rainpoiss commented 7 years ago

Uncaught Exception: ContextErrorException .

ContextErrorException in FieldFactory.php line 94:

contenttype.yml:

 hidefield:
        type: hidden
        fields:
            slug:
                type: slug
                uses: title_et
xiaohutai commented 7 years ago

That construction doesn't make sense to me.

A hidden field is just:

 hidefield:
        type: hidden

and everything under fields is ignored. Unless I'm missing something?

rainpoiss commented 7 years ago

I want to hide slug filed, which type is slug

xiaohutai commented 7 years ago

You want to hide it in the CMS? Then that's not a JSONAPI issue.

If you want to hide it from the JSONAPI output, then configure that in the configuration file jsonapi.bolt.yml:

list-fields: [ ... ]
item-fields: [ ... ]
allowed-fields: [ ... ]

See https://github.com/xiaohutai/jsonapi/blob/master/config/config.yml.dist#L7-L16

rainpoiss commented 7 years ago

Yes I want to hide it in the CMS

xiaohutai commented 7 years ago

If you need a hidden field, then it should be something like:

some_field:
    type: hidden

But then it won't act as a slug anymore (something that you see in the URL), which is probably not what you want.

Alternatively, you can add a custom extension that adds an asset (CSS/JavaScript) that then hides the slug field for that contenttype. See https://docs.bolt.cm/3.3/extensions/bundled/introduction for making your own extensions.

From what I understand, this is not a JSONAPI issue.