0

We are having a problem with converting our current AMP form to a web-to-lead form with SF. Currently the access-control-header is set using our back-end PHP handler which lists our website. I don’t have any experience with changing the action-xhr to anything but an internal link, so how do we get our form to send info to SF for web-to-lead and for access-control-header errors to not block the sending of the form?

Following is the code.

 <?php

    $data['block'] = '1';
    $data['attribute'] = 'h1';
    $data['title'] = $this->lang->line('QUOTE-Breadcrumb-Title');
    $data['subtitle'] = '';
    $this->load->view('amp/sections/templates/heading_block', $data);

    echo '<div class="content">';

    $data['block'] = '';
    $data['attribute'] = 'h2';
    $data['title'] = $this->lang->line('QUOTE-Section-Personal-Title');
    $data['subtitle'] = '';
    $this->load->view('amp/sections/templates/heading_block', $data);

?>

    <form 
        method="POST" 
        action-xhr="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8"
        class="contactForm" 
        target="_top" 
        custom-validation-reporting="show-first-on-submit">
        <input type=hidden name="oid" value="00D_orgId">
        <input type=hidden name="retURL" value="<?php echo base_url($this->session->userdata('lang').'/amp/thanks-enquiry');?>">
        <input type=hidden name="00N4J00000I09MO" id="00N4J00000I09MO" value="<?php echo base_url($this->session->userdata('lang'));?>">
        <fieldset>
            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="first_name"></span>
                <input type="text" name="first_name" placeholder="<?= ucwords($this->lang->line('QUOTE-Section-First-Name'));?>" 
                    class="contactField" id="first_name" required  />
            </div>
            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="last_name"></span>
                <input type="text" name="last_name" placeholder="<?= ucwords($this->lang->line('QUOTE-Section-Last-Name'));?>" 
                    class="contactField" id="last_name" required  />
            </div>
            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="email"></span>
                <span visible-when-invalid="typeMismatch" validation-for="email">
                    Please enter a valid email
                </span>
                <input type="email" name="email" placeholder="<?= ucwords($this->lang->line('QUOTE-Section-Email'));?>" 
                    class="contactField" id="email" required />
            </div>
            <div class="formFieldWrap">
                <select name="00N4J00000F3J94" id="00N4J00000F3J94" class="contactField">
                    <?php
                        echo '<option selected disabled>'.$this->lang->line('QUOTE-Select-Country').'</option>';
                        foreach ($countries as $key => $country) {
                            $name = "name_".strtoupper($this->session->userdata('lang'));
                            echo '<option value ="'.$country->phonecode.'">(+'.$country->phonecode.') - '.$country->$name.'</option>';
                        }
                    ?>
                </select>
            </div>
            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="phone"></span>
                <span visible-when-invalid="typeMismatch" validation-for="phone">
                    Please enter a valid phone number
                </span>
                <input type="tel" name="phone" placeholder="<?= $this->lang->line('QUOTE-Section-Phone');?>" 
                    class="contactField" id="phone" required />
            </div>
            <h2 class="center-text uppercase half-bottom"><?= $this->lang->line('QUOTE-Section-Booking-Title');?></h2>
            <div class="formFieldWrap">
                <select name="00N4J00000F38k6" id="00N4J00000F38k6" class="contactField">
                    <?php
                        echo '<option selected disabled>'.$this->lang->line('QUOTE-Select-Vehicle').'</option>';
                        foreach ($cars as $key => $car) {
                            if ($car_quote == strtolower($car['name'])) {
                                echo '<option value ="'.$car['name'].'" selected>'.$car['name'].'</option>';
                            } else {
                                echo '<option value ="'.$car['name'].'">'.$car['name'].'</option>';
                            }
                        }
                    ?>
                </select>
            </div>

            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="00N4J00000I09MP"></span>
                <amp-date-picker  
                    type="single" 
                    mode="overlay" 
                    format="DD/MM/YYYY" 
                    min = "<?php date("Y-m-d");?>" 
                    input-selector="[name=datestart]"
                    locale="<?= $this->session->userdata('lang');?>">
                    <input type="text" name="datestart" placeholder="<?= $this->lang->line('QUOTE-AMP-Date-Start');?>" 
                        class="contactField" id="00N4J00000I09MP" autocomplete="off" required />
                </amp-date-picker>
            </div>

            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="00N4J00000I09MN"></span>
                <amp-date-picker 
                    type="single" 
                    mode="overlay" 
                    format="DD/MM/YYYY" 
                    min = "<?php date("Y-m-d");?>" 
                    input-selector="[name=dateend]"
                    locale="<?= $this->session->userdata('lang');?>">
                    <input type="text" name="dateend" placeholder="<?= $this->lang->line('QUOTE-AMP-Date-End');?>" 
                        class="contactField" id="00N4J00000I09MN" autocomplete="off" required />
                </amp-date-picker>
            </div>

            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="00N4J00000F38kG"></span>
                <input type="text" name="00N4J00000F38kG" placeholder="<?= $this->lang->line('QUOTE-Section-Pickup');?>" 
                    class="contactField" autocomplete="off" id="00N4J00000F38kG" required />
            </div>
            <div class="formFieldWrap">
                <span visible-when-invalid="valueMissing" validation-for="00N4J00000F38kL"></span>
                <input type="text" name="00N4J00000F38kL" placeholder="<?= $this->lang->line('QUOTE-Section-Dropoff');?>" 
                    class="contactField" autocomplete="off" id="00N4J00000F38kL" required />
            </div>
            <div class="formTextareaWrap">
                <span visible-when-invalid="valueMissing" validation-for="description"></span>
                <textarea name="description" placeholder="<?= $this->lang->line('QUOTE-Section-Alternative');?>" 
                    class="contactTextarea" id="description"></textarea>
            </div>
            <div class="formSubmitButtonErrorsWrap contactFormButton">
                <input type="submit" class="buttonWrap button bg-red-dark contactSubmitButton" 
                    value="<?= $this->lang->line('QUOTE-Section-Button');?>" id="submit" />
            </div>
        </fieldset>
    </form>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.