Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I am using Couch 2.0 on a website and I have a contact form that breaks on submit. When I submit the form it shows an error but it is blank ( I just see the Bootstrap X without any text) and it doesn't redirect. Not sure where I am going wrong:

Code: Select all
<cms:form action='' method="POST" class="b_default_layout">
                           <cms:if k_success>
                              <cms:check_spam email=frm_email />
                              <cms:send_mail from=frm_email to="myemail@email.com" subject='New Contact Form Message'>
                                 The following was submitted via the <cms:show k_page_title /> form:
                                 <cms:show k_success />
                              </cms:send_mail>
                              <cms:redirect url='https://mysite.com/success' />
                              <cms:else />
                              <cms:if k_error>
                                 <div role="alert" class="errorMessage alert alert-danger alert-dismissible">
                                    <button type="button" data-dismiss="alert" aria-label="Close" class="close">
                                       <span aria-hidden="true">x</span></button>
                                    <cms:if k_error_name>Please enter your name.<br/></cms:if>
                                    <cms:if k_error_email>Please enter a valid email address.<br/></cms:if>
                                    <cms:if k_error_phone>Please enter in a phone number.<br/></cms:if>
                                    <cms:if k_error_message>Please enter a message.<br/></cms:if>
                                 </div>
                              </cms:if>
                           </cms:if>
                           <ul>
                              <li class="row">
                                 <div class="col-lg-6 col-md-6 col-sm-6 m_bottom_15">
                                    <label class="second_font required d_inline_b m_bottom_5 clickable" for="cf_name">Name</label><br>
                                    <cms:input type="text" name="name" id="name" placeholder="Name*" class="tr_all w_full fw_light"  required='1' />
                                 </div>
                                 <div class="col-lg-6 col-md-6 col-sm-6 m_bottom_15">
                                    <label class="second_font required d_inline_b m_bottom_5 clickable" for="cf_email">Email Address</label><br>
                                    <cms:input type="text" name="email" id="email" placeholder="Email*" class="tr_all w_full fw_light"  required='1' />
                                 </div>
                              </li>
                              <li class="m_bottom_15">
                                 <label class="second_font d_inline_b m_bottom_5 clickable" for="cf_telephone">Phone*</label><br>
                                 <cms:input type="text" name="phone" placeholder="Phone*" class="tr_all w_full fw_light" id="cf_telephone"  required='1' />

                              </li>
                              <li class="m_bottom_15">
                                 <label class="second_font d_inline_b m_bottom_5 clickable" for="cf_product">Product</label><br>
                                 <cms:input type="text" name="product" placeholder="Product" class="tr_all w_full fw_light" id="product"  />
                              </li>
                              <li class="m_bottom_15">
                                 <label class="second_font required d_inline_b m_bottom_5 clickable" for="cf_message">Message</label><br>
                                 <cms:input class="tr_all w_full fw_light" rows="7" type='textarea' name="message" id="message" placeholder="Message*" required='1'></cms:input>
                              </li>
                              <!--<li class="m_bottom_15">
                                 <cms:input name='recaptcha_test' type='recaptcha'/>
                              </li>-->
                              <div class="clearfix"></div>
                              <li>
                                 <button class="button_type_2 black state_2 tr_all second_font fs_medium tt_uppercase d_inline_b"><span class="m_left_10 m_right_10 d_inline_b">Submit</span></button>
                              </li>
                           </ul>
                        </cms:form>
To troubleshoot such situations you should place a <cms:dump /> in the <cms:form> to get an insight on what is happening e.g. as follows -
<cms:form action='' method="POST" class="b_default_layout">
<cms:dump />
<cms:if k_success>
....

I did that and found that your form is never hitting k_success - even with all the fields filled, there is one error but you are not displaying it (so you just see the Bootstrap 'x' from the error condition).

What I got was this -
Code: Select all
form
k_cur_form: kformname0
k_cur_form_method: post
k_cur_form_separator: |
k_submitted: 1
k_error_recaptcha_test: reCAPTCHA is incomplete
k_error: recaptcha_test: reCAPTCHA is incomplete
k_error_count: 1

As you can see, there is a reCAPTCHA error.

The form as it displays does not show a reCAPTCHA but your code has the following -
Code: Select all
      <!--<li class="m_bottom_15">
         <cms:input name='recaptcha_test' type='recaptcha'/>
      </li>-->

You have used HTML comments <!-- --> to exclude the captcha so it does not show as HTML but that does not hide it from Couch which is still processing it.

The correct way is this -
Code: Select all
<cms:ignore>
    <li class="m_bottom_15">
     <cms:input name='recaptcha_test' type='recaptcha'/>
    </li>
</cms:ignore>

Hope the reply helps.
Thanks KK! That helps a lot. I decided to keep the recaptcha on the form. I have added the keys in the recaptcha config file and for some reason I still get this error in the console:

Code: Select all
VM1450 recaptcha__en.js:401 Uncaught Error: Missing required parameters: sitekey
    at new gs (VM1450 recaptcha__en.js:401)
    at new zs (VM1450 recaptcha__en.js:406)
    at Object.Ms [as render] (VM1450 recaptcha__en.js:415)
    at k_onload_recaptcha_callback ((index):236)
    at ws (VM1450 recaptcha__en.js:422)
    at xs (VM1450 recaptcha__en.js:406)
    at VM1450 recaptcha__en.js:423
    at VM1450 recaptcha__en.js:432
3 posts Page 1 of 1