0

I saw a similar question about Channel Form, but I am wondering if there is a way to save a new form response each time a user edits a previous form response with Freeform.

A second related question to this: if I were to duplicate a form, can the form be prepopulated with a user's answers to the first version of the form, then the response be saved as a response to the new form. (The form is a survey that users will be asked to complete annually; we need to save their responses for each year, but we don't want the users to have to fill out the form from scratch each time as the it is lengthy).

2 Answers 2

0

Sure, wrap the freeform:form tag inside freeform:entries and populate the form with the existing data, then when the form is submitted, it will be a new entry. make sure you pass the entry_id in the url and use that to pull the entry in.

2
  • Thank you Jim for your response. This general method worked beautifully. I do have a follow-up question, though... do you know how to load the values of the previous answers to radio/checkbox/select questions while still making them editable?
    – Amanda
    Commented Feb 15, 2015 at 18:54
  • An example for the above: when I was previously using the standard Freeform edit mode, I would include code like this to determine whether a radio button should be checked: <input name="field_name" id="field_name" value="Yes" type="radio" {if freeform:edit_data:field_name == "Yes"} checked="checked" {/if}> Now, since I have changed "freeform:edit_data" to "freeform:field", it doesn't read the value.
    – Amanda
    Commented Feb 15, 2015 at 19:00
0

I would like to expand on Jim Wyse's advice, and explain what else I have solved so far and what I am still looking for advice on.

First of all, here is the beginning and end code example to do what Jim suggested (where the entry_id is passed through the url):

{exp:freeform:entries
  form_name="my_survey_name"
  entry_id="{segment_3}"
  }
{exp:freeform:form
  form_name="my_survey_name"
  multipage="yes"
  }

<!-- survey questions here -->

{/exp:freeform:form}
{/exp:freeform:entries}

Within this setup, I can easily pre-populate the values from the original entry like this:

For regular text field:

  <input id="field_name" name="field_name" 
        value="{freeform:field:field_name}" type="text">

For radio buttons:

  <input id="field_name" name="field_name" value="Yes" type="radio"
        {if '{freeform:field:field_name}' == "Yes"}
              checked="checked"
        {/if}>

For select menu:

  <select id="field_name" name="field_name">
        <option value="field_value"
              {if '{freeform:field:field_name}' == "field_value"}
                    selected="selected"
              {/if}>Field Value
        </option>
  </select>

These all work correctly, but by this logic I would expect the following to work for checkboxes (same as radio buttons, but replacing the "==" with "*=" to change "equal to" to "contains"). This, however, causes the page to break and nothing will display.

  <input id="field_name" name="field_name" value="field_value" type="checkbox"
        {if '{freeform:field:field_name}' *= "field_value"}
              checked="checked"
        {/if}>

I am hoping someone else might be able to expand on this to solve the checkbox value problem? Thank you in advance!

1
  • It turns out that *= (the conditional operator for "contains") was added to Expression Engine in version 2.9.x. So the example I included above for displaying checkbox selections from previous entry in new form will work fine for anyone using that version of Expression Engine.
    – Amanda
    Commented Feb 17, 2015 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.