Every field goes through FORMFORGE_Field_Types::render( $field ). This static method reads $field['type'] and dispatches to the appropriate renderer.
Rendering Lifecycle
render()is called with the field definition array- Common attributes are computed (name, id, required, placeholder)
- The type-specific renderer produces the inner HTML
- The field is wrapped with label, description, and error placeholder
- The
formforge_field_renderfilter allows modification of the final HTML
Generated HTML Structure
html
<div class="formforge-field formforge-field--text" id="formforge-field-field_1">
<label class="formforge-label" for="formforge_field_field_1">
Full Name <span class="formforge-required">*</span>
</label>
<input type="text"
class="formforge-input"
id="formforge_field_field_1"
name="formforge_field_field_1"
placeholder="John Doe"
required
minlength="2"
maxlength="100">
<span class="formforge-description">Enter your full name</span>
<span class="formforge-field-error" style="display:none;"></span>
</div>Conditional Asset Loading
Forms load CSS/JS only when detected on the current page. Specialized assets (maps, Stripe, conversational) are loaded only when the form uses those features:
php
// Maps script loaded only when a map_address field is present
if ( $has_map_field ) {
wp_enqueue_script( 'google-maps',
'https://maps.googleapis.com/maps/api/js?key=YOUR_KEY&libraries=places',
[], null, true );
wp_enqueue_script( 'formforge-map-field',
FORMFORGE_URL . 'assets/js/map-field.js',
['formforge-frontend'], FORMFORGE_VERSION, true );
}
// Stripe loaded only when a payment field is present
if ( $has_payment_field ) {
wp_enqueue_script( 'stripe-js', 'https://js.stripe.com/v3/', [], null, true );
wp_enqueue_script( 'formforge-stripe',
FORMFORGE_URL . 'assets/js/stripe-field.js',
['formforge-frontend', 'stripe-js'], FORMFORGE_VERSION, true );
}—