<p>I have a custom plugin that uses a custom field leveraging the <code>elementSelect</code> fieldtype to select an asset (which is then processed on submission via a custom service). However, when I select an asset via my field, I get the following JS error in console:</p>

<pre><code>Uncaught Error: Syntax error, unrecognized expression: [data-id="["1286"]"]:first
</code></pre>

<p>The integer above relates to the selected asset.</p>

<p>Has anyone come across this issue before?
It was working previously so not sure if a Craft update has broken it. </p>

<p>The plugin field template:</p>

<pre><code>{% import "_includes/forms" as forms %}
{{ forms.elementSelectField({
        elementType: elementType,
        sourceElementId: value,
        value: value,
        elements: elements,
        sources: volumes,
        label: 'Your asset',
        limit: 1,
        id: name,
        name: name })
}}
</code></pre>

<p>Cole</p>

CC BY-SA 4.0
2018-09-28T20:39:13.677Z
Could you please explain the variables you used? The `value` property for example isn't needed, what value have your `elementType` and `elements` variables?
Robin Schambach
CC BY-SA 4.0
2018-10-02T13:53:42.743Z
Thanks for the reply Robin. The `elementType` is set to 'craft\elements\Asset' and the elements is an array containing a previously saved element (so null if new entry or not specified)
Cole Henley
CC BY-SA 4.0
2018-10-05T18:44:04.810Z
My guess would be that one of your parameters is incorrectly set. Without seeing their values it is tough to troubleshoot this further.
Ben Croker
<plugin-development><assets><craft3><custom-fieldtype>
Custom plugin: asset fieldtype
# Custom plugin: asset fieldtype

(Asked by: username_0 on 2018-09-28)

I have a custom plugin that uses a custom field leveraging the elementSelect fieldtype to select an asset (which is then processed on submission via a custom service). However, when I select an asset via my field, I get the following JS error in console:
Uncaught Error: Syntax error, unrecognized expression: [data-id="["1286"]"]:first

The integer above relates to the selected asset.
Has anyone come across this issue before?
It was working previously so not sure if a Craft update has broken it. 
The plugin field template:
{% import "_includes/forms" as forms %}
{{ forms.elementSelectField({
        elementType: elementType,
        sourceElementId: value,
        value: value,
        elements: elements,
        sources: volumes,
        label: 'Your asset',
        limit: 1,
        id: name,
        name: name })
}}

Cole

**Tags:** plugin-development, assets, craft3, custom-fieldtype
> **Comments:**
> **username_1**: Could you please explain the variables you used? The `value` property for example isn't needed, what value have your `elementType` and `elements` variables?  
> **username_0**: Thanks for the reply Robin. The `elementType` is set to 'craft\elements\Asset' and the elements is an array containing a previously saved element (so null if new entry or not specified)  
> **username_2**: My guess would be that one of your parameters is incorrectly set. Without seeing their values it is tough to troubleshoot this further.  

---

## 0 answers

