PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Display form after submission

  1. paddelboot
    Member

    I am using a form as a content filter, therefore I want it to display the selected values after it has been submitted.
    There doesn't seem to be an option in the backend to set: a text message is displayed but the form is removed, and redirecting makes all the post data unavailable, so I cannot prepopulate the fields.

    How would I do that?

    Paddelboot

    Posted 9 years ago on Thursday July 19, 2012 | Permalink
  2. David Peralty

    Sorry, can you explain more about what you are trying to do? You can create confirmation text that includes the field values. Go to the form, go to edit it, click on the title, go to Confirmation and select Text. Then you can add in the various field elements form the drop down.

    If you want to have it go back to the form, with the form filled out, then you would want to redirect, and add in the query strings, making sure that the fields have Allow Populate Dynamically checked with parameters entered that will be the same as you use in your redirect query string.

    Posted 9 years ago on Thursday July 19, 2012 | Permalink
  3. Paddelboot, would this "pre-submission confirmation" help you at all? Maybe you could adapt part of it for your situation?

    http://gravitywiz.com/2012/04/30/simple-pre-submission-confirmation/

    Posted 9 years ago on Friday July 20, 2012 | Permalink
  4. paddelboot
    Member

    I'll try to explain myself better:

    This form works as a post filter: "Filter posts by:" [date]

    After submission, the selected filters will be appended to the WP_Query meta query object. So far, so good. I simply want to always display the form on top of the loop, with the currently active filters selected.

    Hope that makes sense,

    Paddelboot

    Posted 9 years ago on Friday July 20, 2012 | Permalink
  5. What are you using for your confirmation page? A text confirmation, or a page? I'm not completely sure how this should work in your situation, yet, but can you use a Page redirect, and send the query string to it? That way, the values will be passed in the query string and your form fields can be pre-populated.

    Posted 9 years ago on Friday July 20, 2012 | Permalink
  6. paddelboot
    Member

    So I have to hook into gform_confirmation, use the entry object to create the query string, and then return the redirect URL. Besides from having an additional redirect, should'n it be more easy to just display a form after submit? The POST data is there, so it should be just as easy to prepopulate the form fields.

    Not every form is a contact kind of form. Imagine using forms for entering sets of data, and after each set, you'd have to make a redirect, click the browser's back button or a "Enter new dataset" kind of link. Life could be a lot simpler.

    Still a very nice plugin.

    Paddelboot

    Posted 9 years ago on Friday July 20, 2012 | Permalink
  7. paddelboot
    Member

    By chance I found a solution that seems to work:

    Returning an empty value in the function called by the gform_confirmation hook results in the form being displayed again, with the entered values selected - exactly what I wanted.

    public function custom_confirmation( $confirmation, $form, $lead, $ajax ) {
    
    			switch ( $form[ 'title' ] ) {
    
    				case 'my_form':
    					// Display form after submit, with prepoluated fields
    					return;
    
    				default:
    					return $confirmation;
    			}
    		}

    Paddelboot

    Posted 9 years ago on Friday July 20, 2012 | Permalink
  8. Glad you were able to find a solution which works for you.

    Posted 9 years ago on Friday July 20, 2012 | Permalink

This topic has been resolved and has been closed to new replies.