Mit einer Embed Komponente alle Attachments in einem Attachmentfield zum Download bereitstellen
Beschreibung:
Es gibt momente, da möchte man einfach auf dem Formular alle Attachments in einem Attachment Field als Download link im Formular haben.
Mit einem Repeater Block und darin enthaltenden Embed-Komponente, könnte man das so realisieren:
Quelltext Embed Komponente:
Die variable Attachmaents enthält das AttachmentField aus dem Repeater.
sind keine Attachments droin. Wird einfach der text ausgegeben, No Attachments here.
Im Javascript Teil der Embed-Komponente
const attachments = $("New Repeater block.test.attachments");
if(attachments) {
let html = '';
for (const attachment of attachments) {
html += `<a href="${attachment.url}" download>${attachment.name}</a><br>`;
}
return html;
}
return 'No attachments here';