Jake Vanderwerf
2026-01-19 0113d2e9c9ff34a6ffb10707cc76d34b67a0c367
src/forms/view.js
@@ -9,30 +9,31 @@
 */
class FormBlock {
   constructor() {
      this.controller = new window.jvbForm();
      this.controller = window.jvbForm;
      document.querySelectorAll('.jvb-form-block form').forEach(form => {
         this.controller.registerForm(form, {
            autosave: true,
            autoUpload: false
            autoUpload: false,
            showSummary: true,
         });
      });
      this.controller.subscribe((event, data) => {
         if (event === 'form-submit') {
            this.handleFormSubmission(data);
            this.handleFormSubmission(data).then(()=>{});
         }
      });
   }
   async handleFormSubmission(data) {
      const { formId, config: formConfig, fullData: formData } = data;
      const form = formConfig.element;
   async handleFormSubmission(eventData) {
      const { config, data } = eventData;
      const form = config.element;
      const submitData = new FormData();
      // Add regular form fields
      for (const [key, value] of Object.entries(formData)) {
      for (const [key, value] of Object.entries(data)) {
         if (key === '_wpnonce' || key === '_wp_http_referer') continue;
         if (Array.isArray(value)) {
@@ -56,7 +57,7 @@
         }
      }
      this.controller.showFormStatus(formId, 'uploading');
      this.controller.showFormStatus(config.id, 'uploading');
      try {
         const response = await fetch(`${jvbSettings.api}forms`, {
@@ -68,13 +69,13 @@
         const result = await response.json();
         if (!response.ok) {
            this.controller.showFormStatus(formId, 'error');
            this.controller.showFormStatus(config.id, 'error');
            this.controller.handleFormError(form, result);
            return;
         }
         this.controller.showFormStatus(formId, 'submitted');
         this.controller.showSummary(formId, '.jvb-form-block');
         this.controller.showFormStatus(config.id, 'submitted');
         this.controller.showSummary(config.id, '.jvb-form-block');
         // Clean up uploaded files
         if (window.jvbUploads) {
@@ -87,13 +88,13 @@
      } catch (error) {
         console.error('Form submission error:', error);
         this.controller.showFormStatus(formId, 'error');
         this.controller.showFormStatus(config.id, 'error');
         this.controller.handleFormError(form, {
            message: 'Network error. Please check your connection and try again.',
            code: 'network_error'
         });
      } finally {
         await this.controller.store.delete(formId);
         await this.controller.store.delete(config.id);
      }
   }
}