I have a plugin that lets the user pick an Asset to use, via the following Twig code:
{{ forms.elementSelectField({
elements: elements,
id: id ~ 'imageId',
name: name ~ '[imageId]',
label: 'Recipe Image' |t,
instructions: 'Pick an image that represents this recipe' |t,
elementType: elementType,
criteria: {
'kind': [],
'localeEnabled': null,
},
sourceElementId: value.imageId,
sources: assetSources,
jsClass: 'Craft.AssetSelectInput',
addButtonLabel: "Select an Image" |t,
limit: 1,
}) }}
I pass in the assetSources as follows:
'assetSources' => Asset::sources()
In Craft 2.x, this could be an array of sources; in Craft 3.x, this causes the error below. If I omit sources: assetSources, everything works fine (but I'm not able to limit the asset sources they can choose from).
Description
I have a plugin that lets the user pick an Asset to use, via the following Twig code:
I pass in the
assetSources
as follows:In Craft 2.x, this could be an array of sources; in Craft 3.x, this causes the error below. If I omit
sources: assetSources,
everything works fine (but I'm not able to limit the asset sources they can choose from).Additional info