I*net Systems I*net Systems Clients of I*net Systems Designs at I*net Systems
contact us
find us
follow us
meet us

Breaking up long forms

Recently I had a long form to display on a membership website. I wanted a visitor to be able to leave the form incomplete and then to return to finish it later. My approach with CForms was to break the long form up into a series of very short forms, each to be filled out once. For this explanation, suppose I broke the long form into four short forms. If the visitor completed the first two, I wanted the controlling page to look like:

  • Form 1: the beginning COMPLETE
  • Form 2: the next bit COMPLETE
  • Form 3:  rounding the bend
  • Form 4: the end
  • To accomplish this, I began by adding one hidden field to each form, called Your ID with the default value {CurUserID}.  Because this field is included in all forms, I could use it to determine if the current user had previously submitted a form.

    I didn’t want to compose a new PHP function within CFORMS to select specific records.  If I had, I could have directly determined if the stored forms in the Tracking section contained a record.  Instead, I used an existing CFORM function

    Using the EXEC-PHP plugin to add code to a page, I added the following in the page with links to the forms.

    [exec]
    function isn_did_this_user_submit_form($formname) {
      global $current_user;
    
      /* get the array of submitted forms */
      if ($results = get_cforms_entries($formname)) {
        foreach ($results as $submission) {
          if ($current_user->ID == $submission["data"]["Your ID"]) {
            return(true);
          }
        }
      }
      /* fall out the bottom without finding a submitted form */
      return(false);
    }
    echo '<p>';
    echo 'Fill out and submit the following four forms.  You may stop and restart at any time. ';
    echo '</p>';
    
    echo '<ul style="list-style:none;">';
    
    echo '<li>Form 1:&nbsp;';
    if ( $value = isn_did_this_user_submit_form('NameOfFormGoesHere') ):
      echo 'the beginning &mdash; <em>Complete</em>';
    else:
      echo '<a href="/slug-of-form-page-goes-here">the beginning</a>';
    endif;
    echo '</li>';
    echo '</ul>';

    Leave a Reply

      

      

      

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>