Skip to main content
CloviForms
/
Draft
Add Field
Short Text
Long Text
Email
Phone
Number
URL
Date
Dropdown
Multiple Choice
Checkboxes
File Upload
Star Rating
Hidden Field
Section Break
Signature
Quick Add
AI Generate
Live
Untitled Form
Fill out the form below

No fields yet

Click a field type in the left panel to add it to your form

Click a field in the canvas to edit its settings

`; const res = await fetch('https://clovipdf.com/api/pdf/generate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ html, filename: formName.replace(/\s+/g,'-').toLowerCase() + '-submissions.pdf' }) }); if (res.ok) { const data = await res.json(); const relUrl = data.url || data.output_url; if (relUrl) { window.open('https://clovipdf.com' + relUrl, '_blank'); toast('PDF ready'); return; } } // Fallback: plain print dialog const w = window.open('', '_blank'); w.document.write(html); w.document.close(); w.print(); toast('PDF export opened'); } catch(e) { // Final fallback: print-to-PDF via browser const d2 = _collectSubData(); const w = window.open('', '_blank'); w.document.write(`${formName} Submissions

${formName} — Submissions

${d2.headers.map(h=>'').join('')}${d2.rows.map(r=>''+d2.headers.map(h=>'').join('')+'').join('')}
'+h+'
'+(r[h]??'')+'
`); w.document.close(); w.print(); toast('Print to PDF opened'); } } // ─── AI GENERATE MODAL ──────────────────────────────────────────────────── function openAiModal() { document.getElementById('aiModal').classList.add('open'); document.getElementById('aiPromptInput').focus(); } function closeAiModal() { document.getElementById('aiModal').classList.remove('open'); } document.getElementById('aiModal').addEventListener('click', (e) => { if (e.target === e.currentTarget) closeAiModal(); }); async function runAiGenerate() { const prompt = document.getElementById('aiPromptInput').value.trim(); const docText = document.getElementById('aiDocInput').value.trim(); if (!prompt && !docText) { toast('Describe your form or paste a document'); return; } const btn = document.getElementById('aiGenerateBtn'); btn.disabled = true; btn.innerHTML = ' Generating…'; const fullPrompt = docText ? `Extract form fields from this document and create a form schema. Document:\n\n${docText.slice(0, 3000)}` : prompt; try { const res = await apiFetch('/api/superform/ai-generate', 'POST', { prompt: fullPrompt, platformId: 1 }); if (res.fields && res.fields.length > 0) { fields = res.fields.map(f => ({...f, options: f.options || []})); if (res.formId) { formId = res.formId; formSlug = res.slug; history.replaceState({}, '', '/form-builder.html?formId=' + formId); updatePreviewLink(); } if (prompt) document.getElementById('formNameInput').value = prompt.slice(0, 60); renderFields(); closeAiModal(); toast('✓ ' + fields.length + ' fields generated'); } else { toast('AI did not return fields — try a more specific description'); } } catch (e) { toast('Generation failed: ' + (e.message || 'API error')); } finally { btn.disabled = false; btn.innerHTML = ' Generate Form'; } } init();