<![CDATA[ Back button with FormIt / FormItRetriever - My Forums]]> https://forums.modx.com/thread/?thread=79535 <![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever?page=2#dis-post-536799 this post answer your question?]]> treigh Jan 09, 2016, 02:30 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever?page=2#dis-post-536799 <![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever?page=2#dis-post-536779
Michelle84 could you share your solution?]]>
dubbs Jan 08, 2016, 06:35 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever?page=2#dis-post-536779
<![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438178 Those are from formit I see.
Ah, redirect happens after store. That explains.
And the first function means that for each user, the data is stored in a unique way, if I understand correct.

Well, that's a relief smiley]]>
michelle84 Sep 25, 2012, 08:52 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438178
<![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438175
    /**
     * Gets a unique session-based store key for storing form submissions.
     *
     * @return string
     */
    public function getStoreKey() {
        return $this->modx->context->get('key').'/elements/formit/submission/'.md5(session_id());
    }


    /**
     * Handle post-processing through postHooks
     * @return bool
     */
    public function postProcess() {
        $success = $this->runPostHooks();
        if ($success) {
            /* if store is set for FormItRetriever, store fields here */
            $store = $this->modx->getOption('store',$this->config,false);
            if (!empty($store)) {
                $this->dictionary->store();
            }

            /* if the redirect URL was set, redirect */
            $this->checkForRedirect();

            /* set success placeholder */
            $this->setSuccessMessage();

            /* if clearing fields on success, just end here */
            if ($this->modx->getOption('clearFieldsOnSuccess',$this->config,true)) {
                $this->clearFieldsAtEnd = true;
            }
        }

        return $success;
    }

]]>
Bruno17 Sep 25, 2012, 08:37 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438175
<![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438170 !
It's working (not with the validation check, haven't tried that yet).
I'll post the code later on for others who might be interested.

By the way, before I get carried away, is this a good / safe etc. way to do this?
Is it not possible that data from a wrong user gets displayed in the form?]]>
michelle84 Sep 25, 2012, 08:24 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438170
<![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438167 Why would the redirect hook work, and my own hook not? Doesn't the redirect hook do the same: redirect to another location?]]> michelle84 Sep 25, 2012, 08:16 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438167 <![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438166
you can try to do the redirection with an additional snippet, placed after formit, not in a formit-hook.
To be sure, the form has validated you can set a placeholder or something in your formit-hook and read that placeholder by your snippet, before redirecting.]]>
Bruno17 Sep 25, 2012, 08:09 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438166
<![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438160 michelle84 Sep 25, 2012, 07:18 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438160 <![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438159 Now I want the filled in values to display with formItRetriever, be it going back or forth. It's not working though... I'm going crazy over this ;-)

FORM 1 (ID 22) (this one is just forwarding)
[[!FormIt? &hooks=`redirect` &store=`1` &redirectTo=`30`]]
[[!FormItRetriever]]

<form class="form" action="[[~[[*id]]]]" method="post">
<input type="hidden" name="naam" value="[[!+fi.naam]]" />	
	<label for="content">
	        Reactie:
	        <span class="error">[[+fi.error.content]]</span>
	    </label>
	    <textarea id="reactie" cols="55" rows="7" name="reactie:required:stripTags">[[!+fi.reactie]]</textarea>
	
	<div class="form-buttons">
		<input type="submit" value="Verder!" />
	</div>
</form>


FORM 2 (back and forth)

[[!FormIt? &hooks=`backOrForward` &store=`1`]]
[[!FormItRetriever]]

<form class="form" action="[[~[[*id]]]]" method="post"><input type="hidden" name="nospam:blank" /> <input type="hidden" name="resource_id" value="[[!+fi.id]]" /> 
<input type="hidden" name="genomineerde_id" value="[[!+fi.genomineerde_id]]" />
<input type="hidden" name="reactie_id" value="[[!+fi.reactie_id]]" />


<label for="naam"> Naam: <span class="error">[[+fi.error.naam]]</span> </label> 
<input id="naam" type="text" name="naam:required" value="[[!+fi.naam]]" />

<div class="form-buttons">
<input type="submit" name="previous" value="Terug!" />
<input type="submit" name="next" value="Verder!" />
</div>

</form>


And the snippet I made (backOrForward):

$modx->log(modX::LOG_LEVEL_ERROR,'START BACK OR F0RWARD');

if (isset($_POST['next'])) {
 $modx->log(modX::LOG_LEVEL_ERROR,'next clicked');
	$url = $modx->makeUrl(31);
	$modx->sendRedirect($url);
} else if (isset($_POST['previous'])) {
 $modx->log(modX::LOG_LEVEL_ERROR,'previous clicked');
	$url = $modx->makeUrl(22);
	$modx->sendRedirect($url);
} else {
 $modx->log(modX::LOG_LEVEL_ERROR,'nothing clicked');
	$url = $modx->makeUrl(100);
	$modx->sendRedirect($url);
}


The back and forth forwarding works, but the values are not stored.]]>
michelle84 Sep 25, 2012, 07:16 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438159
<![CDATA[Re: Back button with FormIt / FormItRetriever]]> https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438149
For everything I need, you seem to have the answer Bruno ;-)]]>
michelle84 Sep 25, 2012, 04:18 AM https://forums.modx.com/thread/79535/back-button-with-formit-formitretriever#dis-post-438149