I'm building a module with a form that includes an element select field that I want to restrict to specific volume. So far this is what I have:

{{ forms.elementSelectField({
    label: "Asset"|t('app'),
    id: 'images', 
    name: 'images',
    elementType: 'craft\\elements\\Asset',
    selectionLabel: "Choose"|t('app'),
    criteria: {
        kind: ['images']
}) }}

I can see there is a 'sources' attribute, but I don't know how to structure the value. I've tried:

sources:[1] and the handle sources:['images'] without luck.

1 Answer 1


I am not expert in Craft CMS but this is how it works for me:

Depending on the element type, source is different.

Look at this link how Craft CMS implements this:


Now how assets implement inputsource function:


so the format of sources for asset is like:

['folder:uid in volumefolders table']

and you can easily limit user to select assets from volumes you want.

  • 1
    Works like a dream, thank you so much for this – I'm just pretending to be a developer so only just learning how to wade through the Craft code to figure things out.
    – dmatthams
    Oct 29, 2019 at 10:12
  • @user3788089 you're welcome. Glad to hear that.
    – user9975
    Oct 29, 2019 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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