2.2 KiB
2.2 KiB
Apex Track Experience — WPForms Vehicle Registration Pattern
Architecture
The vehicle registration form uses a custom HTML/JS snippet inside a WPForms HTML Content field that populates a Single Line Text field with CSS class apex-vehicle-field.
How it works
- HTML Content field holds the snippet with cascading dropdowns (make → model → year → color)
- Single Line Text field with CSS class
apex-vehicle-fieldsits elsewhere in the form - JS in the snippet finds this field via
document.querySelector('.apex-vehicle-field input, .apex-vehicle-field textarea')and populates it when the user selects a color - Format:
2022 Red Ferrari F8 Tributo 710(year color make model hp) - When the form submits, WPForms includes that text field's value in the notification and entry
Pitfalls
- Hidden input fields are invisible to WPForms. WPForms only submits its own form field elements. Standalone
<input type="hidden">won't work — the data must go into a WPForms-managed field. - CSS class must be on the WPForms field, not the HTML widget. Add the class in WPForms builder → field settings → Advanced → CSS Classes.
- JS scope with Elementor. The snippet runs inside its own IIFE (
(function(){...})()) to avoid clashing with other scripts on the page. - Use
.onchangeassignments, not inlineonchange=attributes. Elementor's script loading can strip inline event handlers. Assign handlers in the IIFE viaelement.onchange = function(){...}. - The HTML Content field can contain the entire snippet (CSS + HTML + JS + vehicle data). No external files needed.
SMTP configuration
| Detail | Value |
|---|---|
| Server | c1113726.sgvps.net |
| Port | 2525 |
| Encryption | TLS (STARTTLS) |
| Credentials | contact@apextrackexperience.com (stored in WP Mail SMTP) |
Notification gating
WPForms notifications can have a paypal_commerce flag that gates sending. When using "Pay Offline", remove it:
unset($settings["notifications"]["1"]["paypal_commerce"]);
Vehicle data
Inline JSON with makes → models → years → HP ratings. Source at /root/portal-mockup/vehicles.json on Core.