From 907b5a99249780ab17f835152beb4177e2ad628e Mon Sep 17 00:00:00 2001 From: Viktor Miller Date: Sat, 17 Jan 2026 21:59:39 +0900 Subject: [PATCH] fix(07-01): convert dates back to ISO format before form submission Added form submit handler that converts DD.MM.YYYY dates back to YYYY-MM-DD format before submission. This fixes validation error "Bewerbungsfrist is invalid" by ensuring Formidable Forms receives dates in the expected format. Co-Authored-By: Claude Sonnet 4.5 --- templates/provider-dashboard.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/templates/provider-dashboard.php b/templates/provider-dashboard.php index 90395ca..cfb0f0b 100644 --- a/templates/provider-dashboard.php +++ b/templates/provider-dashboard.php @@ -139,7 +139,7 @@ if ( $is_edit_mode ) { }); }, 500); - // Fix date format after user selects a date - replace slashes with dots + // Fix date format after user selects a date - replace slashes with dots for display $(document).on('change', 'input[type="date"], input.frm_date', function() { var field = $(this); var value = field.val(); @@ -148,9 +148,27 @@ if ( $is_edit_mode ) { if (value && value.includes('/')) { var fixedValue = value.replace(/\//g, '.'); field.val(fixedValue); + // Store the original format in a data attribute for form submission + field.data('original-format', value.replace(/\//g, '-')); console.log('Fixed date format from', value, 'to', fixedValue); } }); + + // Before form submission, convert dates back to YYYY-MM-DD format + $('form').on('submit', function() { + $(this).find('input[type="date"], input.frm_date').each(function() { + var field = $(this); + var value = field.val(); + + // Convert DD.MM.YYYY or DD/MM/YYYY back to YYYY-MM-DD + if (value && /^\d{2}[./]\d{2}[./]\d{4}$/.test(value)) { + var parts = value.split(/[./]/); + var isoDate = parts[2] + '-' + parts[1] + '-' + parts[0]; + field.val(isoDate); + console.log('Converted date for submission from', value, 'to', isoDate); + } + }); + }); });