I created a custom utility template. Inside the template, I would like to use the built-in asset select modal for the "Add image" button. Any way to do this please?
The field is just a normal ElementSelect
field with the element type craft\\elements\\Asset
{{ forms.elementSelectField({
label: "Asset"|t('app'),
id: 'assetSelect',
name: 'assetSelect',
elementType: 'craft\\elements\\Asset',
selectionLabel: "Choose"|t('app'),
elements: elements, //array of selected elements
}) }}
-
@ Robin Schambach Sorry, I didn't make myself clear. When we select an image, there is a modal popping up, we can search in the search bar at the top and when we scroll down to the bottom, we'll get more images. I need the exactly same modal as this. Many thx! – yu xia Oct 31 '18 at 21:19
-
-
Can I ask one more question please? Do you know how to limit the asset source? At the back-end, I get the volumeId and in the twig elementselectfield, I code like this
sources: ['volumeId:'~volumeId]
. But it's not working – yu xia Oct 31 '18 at 22:27 -
Include the property
criteria
with the properties for your element query.criteria: {volumeId: 1, folderId: y}
– Robin Schambach Oct 31 '18 at 22:50