Sterc / FormIt

A dynamic form processing Snippet for MODX Revolution
https://docs.modx.com/current/en/extras/formit
33 stars 58 forks source link

FormItRetriever and multi page form #95

Closed crimsonpixel closed 8 years ago

crimsonpixel commented 8 years ago

Having a problem with &store property and FormItRetriever being used for a 3 page form. No errors in log to assist with debugging. First page had fields successfully stored from 2 to 3, but fields on page 2 are not passed on to page 3.

I have posted the issue on the forum https://forums.modx.com/thread/100537/multipage-and-formitretreiver-and-store-issue#dis-post-543300

However, discovered that another user seemed to have a similar issue https://forums.modx.com/thread/100242/multistep-form-with-empty-fields-until-refresh-of-page#dis-post-543304

Possibly an issue with FormItRetriever and &store

If I refresh the page before submitting the form the additional fields from page 2 do appear on page 3.... so the information is being stored but it is not going through to page 3 immediately. Need a resolution as soon as possible to this.

crimsonpixel commented 8 years ago

Bob Ray offered a solution to this issue by adding the amending the following code

In the file: core\components\formit\model\formit\fidictionary.class.php

around line 138, find this code:

public function retrieve() {
       $cacheKey = $this->formit->getStoreKey();
       return $this->modx->cacheManager->get($cacheKey);
}

Change it to:

public function retrieve() {
       sleep(3);  /* add this line */
       $cacheKey = $this->formit->getStoreKey();
       return $this->modx->cacheManager->get($cacheKey);
}

However, the process does seem rather slow now. But at least it works.

joeke commented 8 years ago

Though the provided solution does work, it's not the most elegant solution. It's true that for some the current way of storing the form in the modx cache does not work as smooth as it should. Maybe storing the values in encrypted session variable would be a better solution in this case. Ideally we would add an extra parameter to the FormIt snippet call, for example '&storeLocation' where you can choose 'cache', or 'session', where if you would choose 'session' the form would be stored in a session var.

crimsonpixel commented 8 years ago

It would be great to have the option for &storeLocation property especially for those of us who might not have the necessary skills to create a snippet to store session variables :) :+1:

Jako commented 8 years ago

I don't know why it is stored in the cache and the cache key is somehow identified by the session. Is the session size that limited?

Jako commented 8 years ago

Should be fixed with this commit. Tested on two installations with the same issue.

joeke commented 8 years ago

Version 2.2.11 is out now, where Jako's solution with the storeLocation paramater is implemented: https://modx.com/extras/package/formit