Allows users to save drafts of PloneFormGen forms in progress
pfg.drafts adds support for Plone users to save copies of PloneFormGen forms in progress and restore the saved values later. This removes the need for users to fill out a lengthy form in one sitting.
The package adds a new display option for Form Folders, called “Form View with Drafts”. If selected, a message is shown prompting the user to save a draft of the form. (It also adds an additional button at the bottom of the form which does the same thing.) If the user clicks this, they are presented with a registration form to create a site account with which to associate the saved data. After registration, the form is saved.
When the user returns to the form, if logged in, the form will be repopulated with the saved values automatically. If logged out, the user can click a link to log in and restore their values. Then the form can be submitted normally when the form is complete.
pfg.drafts has been tested with Plone 4 and PloneFormGen 1.6.0.
Drafts are stored in a BTree in a custom tool (portal_fg_drafts), keyed by form UID and user id.
When the form is visited, the custom display template (pfg_draft_view.cpt) calls the portal_fg_draft tool’s retrieveDraft method to repopulate the request form with any saved data for the current form and user. Values in the request take precedence over values from the draft, so the saved values won’t clobber new values after a validation error.
When the form is submitted, it is processed via the custom pfg_draft_validate.vpy script. This augments the submitted values with values from the draft (such as fileuploads that were saved but cannot be repopulated) and then processes the form normally. If the form passes validation, the saved draft (if any) is deleted from the portal_fg_drafts tool.
pfg.drafts was created by Web Collective and David Glick. Thanks to Bryan Wilson and Fulvio Casali.