/** * HVAC TEC Form Fields Injector * * This script manually injects form fields when TEC Community Events * fails to render them properly. This is a workaround for the TEC bug * where forms render with only hidden fields. * * @package HVAC_Community_Events * @since 2.0.0 */ (function($) { 'use strict'; const HVACFormInjector = { /** * Initialize the form field injector */ init: function() { console.log('[HVAC Form Injector] Initializing...'); // Wait for document ready $(document).ready(() => { // Check if we're on a page with TEC form if ($('form[data-datepicker_format]').length > 0) { this.checkAndInjectFields(); } }); }, /** * Check if form fields exist and inject if missing */ checkAndInjectFields: function() { const $form = $('form[data-datepicker_format]'); if (!$form.length) { console.log('[HVAC Form Injector] No TEC form found'); return; } // Check if form has visible fields const visibleInputs = $form.find('input:visible:not([type="hidden"])').length; const textareas = $form.find('textarea:visible').length; if (visibleInputs === 0 && textareas === 0) { console.log('[HVAC Form Injector] Form has no visible fields, injecting...'); this.injectFormFields($form); } else { console.log('[HVAC Form Injector] Form already has fields'); } }, /** * Inject the missing form fields */ injectFormFields: function($form) { // Create form HTML structure matching TEC's expected layout const formHTML = `
Brief summary for search results and previews
Upload an image for your event (JPG, PNG, GIF)