Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
Second site with couch. loving it so far but have become stuck.
If anyone can point me in the right direction i'll be incredibly grateful.

I have a single page site, using the method described in

It uses the technique from
to submit form without page reload.

The form uses client side validation for live checking, and cheesypoofs html5 input technique from

The Problem
The form validates & submits perfectly. I just can't for the life of me figure out how to display success errors, either within form div#success2 or outside div#success1. Preferably they would be in div#success1 in form, not require an id, and lose div#success2.

The contact form is a DBF using form-repair__data.php:
Code: Select all
<?php require_once( '../cms.php' ); ?>
<cms:template title='Repair Booking Form Data' zname='repair_form' clonable='1' zexecutable='0'>
    <cms:editable name='contact_form__name'    required='1' type='text' />
    <cms:editable name='contact_form__email'   zrequired='1' type='text' validator='email' />
    <cms:editable name='contact_form__number'  zrequired='1' type='text' />
    <cms:editable name='contact_form__type'    zrequired='1' type='dropdown'
        opt_values='Please choose=- | Bike | Scooter | Skateboard | Pram | Wheelchair | Other' />
    <cms:editable name='contact_form__desc'    zrequired='1' type='textarea' />
    <cms:editable name='contact_form__detail'  zrequired='1' type='textarea' />
    <cms:editable name='contact_form__when'    zrequired='1' type='dropdown'
        opt_values='Please choose=- | Now | Today | Tomorrow | This week | Next week | Whenever' />
    <cms:editable name='contact_form__consent' zrequired='1' type='checkbox'
        opt_values='I agree' />
<?php COUCH::invoke(); ?>

and form-repair__form.php (simplified):
Code: Select all
<?php require_once( '../cms.php' ); ?>
<cms:template title='Repair Booking Form Form t' executable='0'>
    <cms:editable type='group' name='grp_form' label='Form'>
        <cms:form title='Repair Booking Form Form'
              action="<cms:show k_template_link />"
            <div id="success1" style="display:none;" class="alert -bgc-Positive -c-White">
                <strong>Success#1:</strong> Your application has been submitted.
                <cms:each k_success sep='\n'>
                    <cms:show item /><br>
            <cms:if k_success>
                    contact_form__name   = frm_contact_form__name />
                <div id="success2" class="alert -bgc-Positive -c-White">
                    <strong>Success#2:</strong> Your application has been submitted.
                    <cms:each k_success sep='\n'>
                        <cms:show item /><br>
            <cms:if k_success>
                    <script>console.log(this); window.parent.document.getElementById('success1').style = "display: block;";</script>

                <cms:input name='contact_form__name'    type='bound' />
            <fieldset class="b-form__fieldset">
                <legend>About you</legend>
                <div class="b-form__group">
                    <label class="b-form__label">
                        <input required type="text" name="f_contact_form__name" placeholder="Your name" class="b-input b-form__item">
                        <span class="b-input__help">What would you like to be called.</span>
            <cms:input type='submit' name='submit' value='Submit'/>

<?php COUCH::invoke(); ?>

All pulled into index.php (snippet):
Code: Select all
               <iframe style="display:none;" name="transFrame" id="transFrame"></iframe>

                <article id="formBooking" class="b-contentItem -form">

                        <cms:pages masterpage='c/templates/form-repair__header.php'>
                                <h1 class="b-contentItem__heading"><cms:show main_heading /></h1>
                                <h3 class="b-contentItem__heading -bdBottom -stuntman__bd z-c-White z-bgc-Neutral"><cms:show contact_text />&nbsp;<a class="b-btn -link" href="tel:<cms:get_custom_field 'contact_number_repair' masterpage='c/templates/globals.php' />"><cms:get_custom_field 'contact_number_repair' masterpage='c/templates/globals.php' /></a></h3>
                                <p class="b-contentItem__text"><cms:show description /></p>
                    <cms:pages masterpage='c/templates/form-repair__form.php'>
                            <cms:show grp_form />
Before any deep investigation: placing a form into a richtext region and outputting it as richtext editable is, very probably, a source of trouble.
active topics, google
Free support is never free.. Donate!
Feedback solicited: [NEW] Couch Constructor
Thanks for the response trendoman.
I'd forgotten I'd done that with the richtext region.
I couldn't figure out how to show the form from the template otherwise. I'm sure I'm missing something, so will have another hunt around.
Unless anyone can point me in the right direction.
Edited initial post to show now using editable group to enclose form.
Don't know if that is any better than a richtext, thought at least its not a nested editable region (I now know this is a no no).
Thanks again
Hey, this is a total mess. Result-wise it is best someone codes it for you. Alternatively, some other saint soul would take time to re-teach you several concepts of CouchCMS that seem to be missing. At least review section "Embedding snippets" from tutorials ... /blog.html
active topics, google
Free support is never free.. Donate!
Feedback solicited: [NEW] Couch Constructor
Thanks for the honest words. Am feeling a little lost.
Will read link, (and a lot else I expect) and try to work a better solution again.
Just for info, I inherited one page site which use js to duplicate a form for use in a modal dialog.
I was hoping to use couchcms to replace the js, but got a bit flummoxed.
If anyone reads this, would a clonable template be the best option?
trendoman, a million thanks. Your honesty and pointer saved my frazzled mind.

swapped template for snippet; made sense of iframe and k_success issues, found about 100 bugs/typos in js; etc.

now all seems to be working perfectly. emails sent, form data persisted, success/erro messages displayed, validation client&server done.
Wholeheartedly welcome. Seems you got talent and fixed things in no time. Keep posting more issues :)
active topics, google
Free support is never free.. Donate!
Feedback solicited: [NEW] Couch Constructor
9 posts Page 1 of 1

Who is online

In total there are 4 users online :: 1 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: Google [Bot] and 3 guests