I created a content type called "Products"
I then added an image field and gave the File Directory a path of [current-page:title]
I then created a node (from the products content type) and gave it a title "Towel"
I uploaded a picture, but on my directory, the image got uploaded to drupal/sites/default/files instead of drupal/sites/default/files/towel
I then tried the dev version and same result.
I was using Drupal 8.0.5 so I decided to try it on the latest Drupal 8.1.0 and on a fresh install.
When I did using Alpha, my file got uploaded to drupal/sites/default/Create Products (which is weird, was not expecting my content type here).
I then decided to try the dev version, and it did not create a folder, was uploading to drupal/sites/default/files (again like on 8.0.5)
I then decided to switch back to the Alpha version, and now is not even created the weird Create Products folder. It's uploading to drupal/sites/default/
Something weird is going on here...
Comment | File | Size | Author |
---|---|---|---|
#17 | current_page_title_-2714257-17.patch | 3.51 KB | hussainweb |
#13 | current_page_title_-2714257-13.patch | 3.5 KB | hussainweb |
#9 | current_page_title_-2714257-9.patch | 2.2 KB | hussainweb |
#9 | current_page_title_-2714257-9-tests-only.patch | 1.52 KB | hussainweb |
Comments
Comment #2
No Sssweat CreditAttribution: No Sssweat commentedComment #3
No Sssweat CreditAttribution: No Sssweat commentedComment #4
NetNerdy CreditAttribution: NetNerdy commentedsame problem and a little bit confusing...
on "add content" or "creation page" runs the token "current-page:title" ...on the "edit page" doe's it nothing
...see screenshots attached
Comment #5
BerdirThis is likely a duplicate of #2675738: "Array to string conversion in Drupal" in Forum. If you check our log, you probably have similar errors as posted there.
Comment #6
No Sssweat CreditAttribution: No Sssweat commented@Berdir
I was able to work around this bug by using https://www.drupal.org/project/filefield_paths module. This module gives you Node tokens which did the trick.
I used the [node:title] token instead of [current-page:title]
Comment #7
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedI think the result of the title resolver service should be processed by token_render_array_value. TitleResolverInterface::getTitle returns array, string or null.
Comment #8
BerdirNice, a test would be great.
Given #2675738: "Array to string conversion in Drupal" in Forum, I think we could test it by placing a block with the current page title token and visiting the forum page.
Comment #9
hussainwebI repurposed an existing route in one of the test modules to return a title as an array.
Comment #12
BerdirNice, works for me. But lets add a comment to explain why we're doing this (could be as part of the currently missing docblock for that method) and also some kind of assert in a test, the one that already visits that page works for me.
Comment #13
hussainwebI added the comments and assert. Since the patch is small, I hope interdiff is not required. :)
Comment #16
hussainwebThe problem is that the title is 'Available Tokens | Drupal' instead of just 'Available Tokens'. I will work on this later today.
Comment #17
hussainwebI am not sure if it is good to assert 'Available Tokens | Drupal' but here goes.
Comment #19
BerdirYeah, that's fine. Thanks!