<p>Sadly there is very little documentation around this. Use <code>criteria</code> like this. I've also tested <code>siteId</code> which worked. I'm sure there are more criterias available.</p>
<pre><code>{{ forms.elementSelectField({
  label: 'Blog post',
  name: 'blogpost',
  elementType: 'craft\\elements\\Entry',
  selectionLabel: 'Select your blog post',
  showSiteMenu: true,
  criteria: {
      section: ['blogposts'],
      siteId: 1
  },
  limit: 1,
  required: true
}) }}
</code></pre>
<p><a href="https://github.com/craftcms/cms/blob/60881865f1b680c5aa5d4ad8f56d9a1ce3e452b0/src/fields/BaseRelationField.php#L843" rel="nofollow noreferrer">Link to the relevant Craft CMS source code.</a></p>

CC BY-SA 4.0
2021-10-28T06:48:32.177Z
2021-10-28T06:48:32.177Z
PWL
<p>How do I limit this elementSelectField to only allow entries within a certain section?</p>
<pre><code>{{ forms.elementSelectField({
  label: 'Blog post',
  name: 'blogpost',
  elementType: 'craft\\elements\\Entry',
  selectionLabel: 'Select your blog post',
  showSiteMenu: true,
  limit: 1,
  required: true
}) }}
</code></pre>

<craft3><plugin-development><form>
Limit elementSelectField to specific sections
# Limit elementSelectField to specific sections

(Asked by: username_0 on 2021-10-28)

How do I limit this elementSelectField to only allow entries within a certain section?
{{ forms.elementSelectField({
  label: 'Blog post',
  name: 'blogpost',
  elementType: 'craft\\elements\\Entry',
  selectionLabel: 'Select your blog post',
  showSiteMenu: true,
  limit: 1,
  required: true
}) }}

**Tags:** craft3, plugin-development, form

---

## 1 answers

### Answer by username_0 on 2021-10-28. Score: 1 | Accepted answer

Sadly there is very little documentation around this. Use criteria like this. I've also tested siteId which worked. I'm sure there are more criterias available.
{{ forms.elementSelectField({
  label: 'Blog post',
  name: 'blogpost',
  elementType: 'craft\\elements\\Entry',
  selectionLabel: 'Select your blog post',
  showSiteMenu: true,
  criteria: {
      section: ['blogposts'],
      siteId: 1
  },
  limit: 1,
  required: true
}) }}

Link to the relevant Craft CMS source code.


---

