17. Form Rendering Pipeline | Form Forge - Build Forms with AI in Seconds
Download Log in

17. Form Rendering Pipeline

Developer Guide

Every field goes through FORMFORGE_Field_Types::render( $field ). This static method reads $field['type'] and dispatches to the appropriate renderer.

Rendering Lifecycle

  1. render() is called with the field definition array
  2. Common attributes are computed (name, id, required, placeholder)
  3. The type-specific renderer produces the inner HTML
  4. The field is wrapped with label, description, and error placeholder
  5. The formforge_field_render filter 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 );
}

Forge AI Assistant Online

Hi! I'm the Form Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs