I have a asset field where I would like to save the images in dynamic folders. The upload folder should be parsed for the Dropdown field values in a Matrix field.

For a normal Dropdown field it works with

{{ object.dropdownFieldHandle }} 

but for a Dropdown field in a Matrix field i can't get it working.

Any help is very appreciated. Thank you in advance.


If you have an Asset field outside of Matrix and you want to set its "Upload Location" to be a dynamic value of Dropdown field inside of a separate Matrix field, something like this should work:

{{ object.matrixFieldHandle.type('matribBlockHandleTheFieldLivesIn').first().dropdownFieldHandle.value }}
  • Thank you Brad, i tried this and it didn't work. That's why i'm not sure if i asked my question properly. The asset field is not in the matrix field, just the dropdown field is in a matrix field. My intention was to dynamically upload the assets sorted by manufacturer. And because there are a lot of different manufacturer for different product types i wanted to choose them per matrix field where each blocktype is a product type with a dropdown field for the manufacturers. Is that possible?
    – TomS
    Feb 5 '18 at 21:00
  • Ahh... I misunderstood, I think. The Asset field is not in a Matrix field, just the dropdown. What's the name of the Matrix block the dropdown field lives in? And is all of this in the context of a Commerce product? And if so, does it have variants enabled?
    – Brad Bell
    Feb 5 '18 at 23:09
  • Yes, the asset field is not in a Matrix field. The name of the matrix block where the dropdown field lives in is "manufacturerMountainbikes". The Matrix field "manufacturer" lives in the product field layout of a commerce product type. Yes i have variants enabled for color, framesize.
    – TomS
    Feb 6 '18 at 10:34
  • Updated the answer... hope that helps.
    – Brad Bell
    Feb 7 '18 at 2:22

I gave up my project to dynamically upload assets through matrix field dropdown values where the asset field is outside of the matrix field. I actually just wanted to save assets in a logical structure. I now save my craft commerce assets like this: product category/manufacturer/productionyear

{{ object.categoryFieldHandle.first.slug }}/{{ object.dropdownFieldHandle }}/{{ object.dropdownFieldHandle }}

Maybe this helps someone.

@Brad Bell thanks for helping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.