So, a date field can be added to a plugin template within the control panel using:

{% from "_includes/forms" import date %}
{{ date({
        id: 'fields-invoiceDate',
        name: 'fields[invoiceDate]'
}) }}

But how do you go about adding an assets field a similar way?

1 Answer 1


Something like this...

{{ forms.elementSelect({
    id: 'invoicePdf',
    name: 'fields[invoicePdf]',
    elementType: craft.elements.getElementType("Asset"),
    elements: invoice.invoicePdf | default,
    criteria: {"kind":[],"localeEnabled":null,"locale":"en_gb"},
    jsClass: 'Craft.AssetSelectInput',
    addButtonLabel: 'Upload invoice',
    limit: 1,
    sources: ['folder:1']
}) }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.