Closed richhayler closed 2 years ago
Thanks for pointing that out! Just fixed for the next release.
Craft 4.0.3 is out now with that fix.
I have updated to 4.0.3 and it's now working as expected using {slug}
in the sub folder path.
Should I be able to use access globalSet variables in the folder subpath? - e.g. I have a globalSet named "global" with a text field, "mytext" (which is a single word, no spaces)?
If I use {global.mytext}
this results in an error stating that "the field’s Asset Location setting has an invalid subpath (“{global.domain}”)".
craft\errors\InvalidSubpathException: Could not resolve the subpath “{global.domain}”. in /craft/vendor/craftcms/cms/src/fields/Assets.php:855
Stack trace:
#0 /craft/vendor/craftcms/cms/src/fields/Assets.php(955): craft\fields\Assets->_resolveVolumePathToFolderId()
#1 /craft/vendor/craftcms/cms/src/fields/Assets.php(495): craft\fields\Assets->_determineUploadFolderId()
#2 /craft/vendor/craftcms/cms/src/fields/Assets.php(565): craft\fields\Assets->craft\fields\{closure}()
#3 /craft/vendor/craftcms/cms/src/base/Element.php(4512): craft\fields\Assets->afterElementSave()
#4 /craft/vendor/craftcms/cms/src/services/Elements.php(2696): craft\base\Element->afterSave()
#5 /craft/vendor/craftcms/cms/src/services/Elements.php(766): craft\services\Elements->_saveElementInternal()
#6 /craft/vendor/craftcms/cms/src/controllers/GlobalsController.php(221): craft\services\Elements->saveElement()
#7 [internal function]: craft\controllers\GlobalsController->actionSaveContent()
#8 /craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#9 /craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#10 /craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#11 /craft/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction()
#12 /craft/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction()
#13 /craft/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest()
#14 /craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#15 /craft/web/index.php(19): yii\base\Application->run()
#16 {main}
Next craft\errors\InvalidSubpathException: The Logo field’s Asset Location setting has an invalid subpath (“{global.domain}”). in /craft/vendor/craftcms/cms/src/fields/Assets.php:980
Stack trace:
#0 /craft/vendor/craftcms/cms/src/fields/Assets.php(495): craft\fields\Assets->_determineUploadFolderId()
#1 /craft/vendor/craftcms/cms/src/fields/Assets.php(565): craft\fields\Assets->craft\fields\{closure}()
#2 /craft/vendor/craftcms/cms/src/base/Element.php(4512): craft\fields\Assets->afterElementSave()
#3 /craft/vendor/craftcms/cms/src/services/Elements.php(2696): craft\base\Element->afterSave()
#4 /craft/vendor/craftcms/cms/src/services/Elements.php(766): craft\services\Elements->_saveElementInternal()
#5 /craft/vendor/craftcms/cms/src/controllers/GlobalsController.php(221): craft\services\Elements->saveElement()
#6 [internal function]: craft\controllers\GlobalsController->actionSaveContent()
#7 /craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#8 /craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#9 /craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#10 /craft/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction()
#11 /craft/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction()
#12 /craft/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest()
#13 /craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#14 /craft/web/index.php(19): yii\base\Application->run()
#15 {main}
You would need to use normal Twig syntax for that ({{ global.mytext }}
). The {shorthand}
syntax is exclusively for properties of the entry being saved (or the Matrix block if the Assets field is nested in a Matrix field.)
Thank you for responding and providing those tips!
What happened?
Description
Upload button not displayed on file selection modal due to twig variable used in sub folder path for a path that doesn't exist, e.g. if using
{slug}
in the folder pathSteps to reproduce
{slug}
in the subfolder pathExpected behavior
Event though the folder for the slug doesn't appear (as this would be created when the entry is created), the upload button should be displayed in the file selection modal.
Craft CMS version
4.0.2
PHP version
8.1.5
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
-