Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-31T21:19:26.717Z
Answers.Text: @ 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!
Answers.UserDisplayName: yu xia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-31T21:20:36.057Z
Answers.Text: Yeah and the script will add a button to open this modal
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-31T22:27:47.193Z
Answers.Text: 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
Answers.UserDisplayName: yu xia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-31T22:50:33.970Z
Answers.Text: Include the property `criteria` with the properties for your element query. `criteria: {volumeId: 1, folderId: y}`
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-31T07:48:02.667Z
Answers.LastActivityDate: 2018-10-31T07:48:02.667Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <plugin-development><templating><control-panel><garnish>
Title: How can I use asset select modal in utility?
ThreadText: # 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`
  
  ```twig
  {{ 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 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}`  
  
  ---
  
  