Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have an issue with a data-bound form.

To avoid anything being down to my own errors, I've copied the exact text from https://docs.couchcms.com/concepts/databound-forms.html (where it says "The final code of our applications template") into another file on my site, and visited that page whilst logged in to admin.

I've also copied the lines:
Code: Select all
require_once( K_COUCH_DIR.'addons/data-bound-form/data-bound-form.php' );
require_once( K_COUCH_DIR.'addons/cart/session.php' );

into kfunctions.php in the couch/addons directory.

So my set up now should be exactly as expected in the databound forms tutorial. (I have one other simple template registered in the admin panel, but I don't think that should be relevant).

If I try to add an entry using the admin panel, and breach the validaton requirements (for example, leaving the surname blank), I get error messages, as expected.

If I use the form in the front end, however,
  • if I fail to complete the 'human' question (where the validator is in the form itself), I get an error message
  • if I fail to complete the surname (a required field, set in the template) I don't get an error reported
  • ...and I do get the 'Success: Your application has been submitted' message
  • ...but the data has not in fact been added to the database.
  • If I complete all required fields, then the form is submitted successfully.

Is this a similar issue to the one in viewtopic.php?f=4&t=11746, or something else? And if there is a need to make a second success check, what is the code I need in this case?

It does seem odd that the exact code shown in the documentation would not work; does it need updating?
Things have changed somewhat with Couch v2.0 and the documentation hasn't kept pace with it.
Please use the second k_success check as shown in viewtopic.php?f=4&t=11746#p31681

Hope it helps.
Thanks, KK, that's fixed it!

For ease of reference, the code for the form now starts:
now is
Code: Select all
 <cms:form
        masterpage=k_template_name
        mode='create'
        enctype='multipart/form-data'
        method='post'
        anchor='0'
        >

       <cms:if k_success >
        <!- this success indicates that the form was submitted without any errors -->
        <cms:db_persist_form
          _invalidate_cache='0'
          _auto_title='1'
        />
        </cms:if>
        <cms:if k_success >
          <h4>
            Your form was submitted sucessfully
          </h4>
        </cms:if>[/b]

        <cms:if k_error >
            <div class="error">
                <cms:each k_error >
                    <br><cms:show item />
                </cms:each>
            </div>
        </cms:if>


.. and this now works "as advertised" in the documentation.

A quick update to the docs might save a string of this sort of question on the forums! I thought it might be the same issue, but the situation was sufficiently different for that to be unclear, and when sample code doesn't work it's always worrying!
3 posts Page 1 of 1