15 lines
No EOL
479 B
JavaScript
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; |