After installing token alpha 2 when submiting a image field (existing one in my case) I get this error :

The File directory is using the following invalid tokens: [date:custom:Y], [date:custom:m].

I've found several closed issues (fixed) about this problem in dev version. Might be a regression?

A similar issue is still open here though: https://www.drupal.org/node/2656240

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

progzy created an issue. See original summary.

Berdir’s picture

Status: Active » Postponed (maintainer needs more info)

This was fixed with test coverage in #2642160: Needs tests: Default file field tokens ([date:custom:Y]-[date:custom:m]) fail Token validation.. Are you sure you are using the latest version? The fix should be in alpha2.

progzy’s picture

I've installed a fresh Drupal 8.0.3 and the problem does not appear. This is the case on the website I am working on though.

However I've just managed to solve it this way (could be helpful if someone encounters the same issue):
- Edit the field ,remove the token from "File directory" text field and save the field settings
- Edit it again and re-add the token ([date:custom:Y]-[date:custom:m]) in "File directory" text field and save again

I thought I would have to do this for all my content type owning an image/file field but it seems to work for all of them with only one manipulation.

Weird ...

bucefal91’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.x-dev
Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.14 KB

I just hit a very similar issue when I tried to specify some tokens in the file's "destination" folder.

In my case I wanted it to be monthly-reports/[node:field_report_date:date:html_month]; we build these nodes automatically and we do provide into the token the corresponding $node object. It seems logical to allow tokens based on the entity type the "file" field is attached to. So I did this as a patch. :)

I do recognize core "file" field will not support tokens based on the entity the file is attached to but in our case we generate these nodes programmatically and we do supply the necessary token $data to make it happen.

jollysolutions’s picture

Status: Needs review » Reviewed & tested by the community

Works for me RTBC

Berdir’s picture

> I do recognize core "file" field will not support tokens based on the entity the file is attached to but in our case we generate these nodes programmatically and we do supply the necessary token $data to make it happen.

Sounds like it is your responsibility then to add the token types in the UI as well? token.module can't add token types that then won't work?

jollysolutions’s picture

Status: Reviewed & tested by the community » Needs work

Spoke too soon. Does not want to upload file. It is trying to create the directory as the token name and not the value.

Berdir’s picture

Yeah, that's exactly what I mean. just documenting it doesn't make it work. Thanks for proving my point ,)