Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi again!

I'm working on a behemoth of a form (which is a survey for some engineering equipment). As it turned out the multi-forms addon was a bit too unreliable for different reasons. I realised that having multiple data-bound-forms would be the better approach, as data would be saved to the template after each step and one could actually continue the whole survey at a much later point as I can controll the different steps easily.

However I would like to have two 'submit' options with the forms - as in the multi-forms-addon - with one option of submitting the current form and continuing to the next, and one submitting but going to the previous one. As all submits carry a value, I was wondering if it's possible to access this and act on it, or is there a different way to achieve this in a simple way?
'Save and go back' submit button can have a click event listener attached to it, with code setting a flag (hidden input) for backend.

It is wise to save forms live via ajax after filling each field to achieve various benefits.
Need assistance? PM or email me.

active topics
Hi,

As a more direct alternative to what @trendoman suggested, you may use <cms:gpc> tag (https://docs.couchcms.com/tags-reference/gpc.html) in the form's success condition to figure out which submit button was used e.g. try this -
Code: Select all
<cms:form  method="post">
    <cms:if k_success>
        <cms:set action="<cms:gpc 'action' />" />
        <cms:if action='update' >
            <h2>Do Update</h2>
        <cms:else_if action='delete' />
            <h2>Do Delete</h2>
        </cms:if>
    </cms:if>

    <cms:input type='text' name='my_text' />
   
    <input type="submit" name="action" value="update" />
    <input type="submit" name="action" value="delete" />
</cms:form>
That's wonderful, thank you!
4 posts Page 1 of 1

Who is online

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

Users browsing this forum: No registered users and 4 guests