<p>The field is just a normal <code>ElementSelect</code> field with the element type <code>craft\\elements\\Asset</code></p>

<pre class="lang-twig prettyprint-override"><code>{{ forms.elementSelectField({
    label: "Asset"|t('app'),
    id: 'assetSelect', 
    name: 'assetSelect',
    elementType: 'craft\\elements\\Asset',
   selectionLabel: "Choose"|t('app'),
   elements: elements, //array of selected elements 
 }) }}
</code></pre>

CC BY-SA 4.0
2018-10-31T21:19:26.717Z
@ 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
CC BY-SA 4.0
2018-10-31T21:20:36.057Z
Yeah and the script will add a button to open this modal
Robin Schambach
CC BY-SA 4.0
2018-10-31T22:27:47.193Z
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
CC BY-SA 4.0
2018-10-31T22:50:33.970Z
Include the property `criteria` with the properties for your element query. `criteria: {volumeId: 1, folderId: y}`
Robin Schambach
CC BY-SA 4.0
2018-10-31T07:48:02.667Z
2018-10-31T07:48:02.667Z
Robin Schambach
<p><a href="https://i.sstatic.net/i5uzm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/i5uzm.png" alt="enter image description here"></a></p>

<p>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?</p>

<plugin-development><templating><control-panel><garnish>
How can I use asset select modal in utility?
# How can I use asset select modal in utility?

(Asked by: username_0 on 2018-10-31)

[![enter image description here](https://i.sstatic.net/i5uzm.png)](https://i.sstatic.net/i5uzm.png)

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?

**Tags:** plugin-development, templating, control-panel, garnish


---

## 1 answers

### Answer by username_1 on 2018-10-31. Score: 2 | Accepted answer

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 
 }) }}

> **Comments:**
> **username_0**: @ username_1 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!  
> **username_1**: Yeah and the script will add a button to open this modal  
> **username_0**: 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  
> **username_1**: Include the property `criteria` with the properties for your element query. `criteria: {volumeId: 1, folderId: y}`  

---

