bigly-chat/comp/form.js
2024-11-25 14:12:43 -05:00

15 lines
No EOL
479 B
JavaScript

function form(elems, action) {
elems.push({
'label': 'Submit',
'type': 'Submit',
'name': 'submit'
});
let mapped = elems.map(elem =>
`<span class='form-entry'> <span class='form-key'>${elem.label}</span> <input type='${elem.type}' name='${elem.name}'></span>`
).join('\n');
return `<form enctype='multipart/form-data' method='POST' action='${action}'><div class='form-message'></div>${mapped}</form>`
}
export default form;