Skip to content

Conversation

@wotis
Copy link

@wotis wotis commented Jan 19, 2026

Problem Description

When using two forms via shortcode on the same page, AJAX submission can fail or hang at the "waiting" message. This issue is particularly evident when the first form is hidden due to time/date constraints while the second form is visible and being submitted.

Steps to Reproduce

  1. Create two forms (e.g., with IDs 51 and 52)
  2. Add both to a page using shortcodes: [cforms]51[/cforms] and [cforms]52[/cforms]
  3. Configure first form with date/time restrictions so it's not displayed
  4. Try to submit the second form via AJAX
  5. Observe that the "waiting" message does not disappear

Root Cause

  1. Orphaned HTML elements: Forms hidden by time constraints still create HTML message box elements (<div id="usermessage...a">) even though the form itself is not rendered
  2. Missing AJAX error handling: No error handling for invalid responses or AJAX failures
  3. JSON corruption: Additional output can corrupt JSON responses from the server

Changes Made

In lib_render.php (lines 116-123)

  • Move cforms2_check_time() check before creating any HTML elements
  • Prevents orphaned message boxes for forms that won't be displayed
  • Remove duplicate time check logic later in the file

In lib_ajax.php (lines 20-23)

  • Add ob_clean() to clear any previous output before sending JSON
  • Ensures clean JSON responses without corrupted data

In js/cforms.js (lines 185-202)

  • Replace jQuery.post() with jQuery.ajax() for better error handling
  • Add response validation to check for valid JSON structure
  • Add error handler for AJAX failures
  • Use configured failure messages instead of technical error output

Testing

Tested with:

  • ✅ Two forms (IDs > 50) on same page
  • ✅ First form hidden by date restrictions
  • ✅ Second form submits successfully via AJAX
  • ✅ Error conditions handled gracefully with user-friendly messages
  • ✅ Works with both forms visible
  • ✅ Works with only one form visible

Impact

This fix ensures that:

  • Multiple forms can coexist on the same page
  • Time-restricted forms don't interfere with other forms
  • AJAX errors are handled gracefully
  • Users see configured error messages, not technical output
  • Form submissions are reliable even under load

Affected Versions

  • cforms2 version 16.0.1
  • WordPress 5.2+
  • Tested on IONOS hosting

Wolfgang Tischer and others added 5 commits September 22, 2025 18:36
✅ MAJOR RELEASE - TIMEZONE-FIX UND MODERNE FEATURES:

🔧 TIMEZONE-HANDLING KOMPLETT ÜBERARBEITET:
- Korrekte lokale Zeit-Speicherung und -Anzeige
- WordPress Timezone-Integration
- Behebung des Timezone-Shift Problems
- Konsistente DateTime-Behandlung

🎨 MODERNES ADMIN-INTERFACE:
- Responsive Design für mobile Geräte
- Moderne CSS-Styles (admin-modern.css)
- Mobile-optimierte Admin-Oberfläche
- Verbesserte Benutzerfreundlichkeit

🧩 GUTENBERG INTEGRATION:
- Vollständige Block-Editor Unterstützung
- Neue blocks/ Verzeichnis-Struktur
- Moderne WordPress-Integration

🛡️ SICHERHEIT UND STABILITÄT:
- Neue Sicherheitsbibliothek (lib_security.php)
- Verbesserte Internationalisierung (lib_i18n.php)
- Erweiterte Block-Funktionalität (lib_blocks.php)

📱 MOBILE RESPONSIVE:
- Mobile-Admin CSS (mobile-admin.css)
- Responsive Design (mobile-responsive.css)
- Touch-optimierte Bedienung

🔄 KERN-VERBESSERUNGEN:
- Erweiterte FormSettings.php
- Optimierte cforms.php
- Verbesserte lib_functions.php
- Überarbeitete lib_options_sub.php

Diese Version löst das ursprüngliche Timezone-Problem und
bringt cforms2 auf den neuesten Stand der WordPress-Entwicklung.
✅ STABLE TAG AKTUALISIERT:
- Stable tag von trunk auf 16.0.0 geändert
- Korrekte Versionsnummer für WordPress Plugin Directory

✅ CHANGELOG FÜR VERSION 16.0.0 HINZUGEFÜGT:
- Vollständige Feature-Liste für Major Release
- Timezone-Fix als Hauptfeature hervorgehoben
- Moderne WordPress-Features dokumentiert
- Responsive Design und Gutenberg Integration erwähnt
- Sicherheits- und Performance-Verbesserungen aufgelistet

✅ DOKUMENTATION VERVOLLSTÄNDIGT:
- Alle neuen Features von Version 16.0.0 dokumentiert
- Technische Verbesserungen detailliert beschrieben
- Benutzer-relevante Änderungen hervorgehoben

Die readme.txt ist jetzt vollständig für Version 16.0.0 aktualisiert
und bereit für die Veröffentlichung im WordPress Plugin Directory.
✅ ROADMAP AKTUALISIERT FÜR VERSION 16.0.0:
- Gutenberg Integration als abgeschlossen markiert ✅
- Enhanced Security als abgeschlossen markiert ✅
- Mobile Admin Interface als abgeschlossen markiert ✅
- CSS/Responsive Design als teilweise abgeschlossen markiert ✅

✅ ERLEDIGTE FEATURES DOKUMENTIERT:
- Gutenberg equivalent of editor plugin (completed in v16.0.0)
- Enhanced security and input filtering (completed in v16.0.0)
- Improve mobile admin interface (completed in v16.0.0)
- Modernize CSS and responsive design (partially completed in v16.0.0)

✅ ROADMAP TRANSPARENZ:
- Benutzer sehen jetzt klar, was bereits implementiert wurde
- Verbleibende Aufgaben sind weiterhin sichtbar
- Version 16.0.0 Achievements werden gewürdigt

Die Roadmap reflektiert jetzt korrekt den aktuellen Stand
und die Errungenschaften von Version 16.0.0.
✅ BEREINIGUNG NACH BENUTZER-FEEDBACK:
- mobile-responsive.css entfernt (war für Frontend gedacht)
- Nur mobile-admin.css beibehalten (nur Admin-Interface)
- Frontend bleibt unverändert wie gewünscht

✅ KLARSTELLUNG:
- mobile-admin.css: Nur Admin-Interface Optimierung
- Keine Frontend-Änderungen
- Fokus auf Admin-Benutzerfreundlichkeit

✅ ERGEBNIS:
- Saubere, fokussierte mobile Admin-Optimierung
- Frontend bleibt original
- Keine unnötigen Dateien mehr

Version 16.0.0 konzentriert sich jetzt korrekt nur auf
Admin-Interface Verbesserungen ohne Frontend-Änderungen.
When two forms are present on a page (especially when one is hidden due
to time constraints), AJAX submissions could hang at "waiting" message.

Changes:
- Move time constraint check before HTML element creation to prevent
  orphaned message boxes for hidden forms
- Add robust AJAX error handling with response validation
- Use configured failure messages instead of technical error output
- Clear output buffer before JSON response to prevent parsing errors

Fixes issue where second form's AJAX submission would not complete when
first form was present but hidden by date/time restrictions.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant