The attached patch makes use of Drupal 5.x's ability to have multistep forms. It adds a "pagebreak" component type, which can be used to split the form up. When this happens, the user is presented with "Next Page" and "Previous Page" submit buttons, as needed.

Intermediate data is efficiently stored in the PHP session, rather than in hidden fields in the form itself.

Comments

gribnif’s picture

StatusFileSize
new7.75 KB

I discovered that my previous patch did not properly restore values to fields that were contained in a fieldset when using the "Previous Page" button. This version addresses that problem. I also generated the patch in a way that should apply better to the current HEAD.

gribnif’s picture

StatusFileSize
new1.33 KB

Grrr. I used SVN to generate that last patch, so it excluded the attached file. Save it in the components directory with the name pagebreak.inc.

Anonymous’s picture

This patch is awesome with one problem, you should not disable control of the component weight, otherwise there is no way to set where the pagebreak should occur.

I really hope this gets commited!

Anonymous’s picture

Another problem, it doesn't seem to restore values properly when traversing pages (previous page for example)

quicksketch’s picture

I've almost certainly broken this patch's implementation with the changes to the 5.x branch. Form elements are now assigned a key so they don't use that cryptic timestamp as a their id/name attributes. Could you re-roll for 5.x?

This is a totally rockin' feature btw.

gribnif’s picture

Status: Needs review » Needs work

I had already solved both of cpisto's problems, and just hadn't gotten around to reuploading yet. I guess it's just as well!

I'll download a new version and rework the patch soon.

quicksketch’s picture

Thanks! Keep an eye out for http://drupal.org/node/141407 also. Just be aware that fieldsets are already broken, and not caused by your changes.

gribnif’s picture

Status: Needs work » Needs review
StatusFileSize
new7 KB

Here's an updated version of the patch, written against 1.113.2.18 2007/05/06. It includes the fixes to cpisto's bug reports.

Please remember that you also need to rename pagebreak_inc.txt (in the next post) to pagebreak.inc and put it into the components folder.

gribnif’s picture

StatusFileSize
new1.23 KB

Updated pagebreak.inc file. Rename to pagebreak.inc and put it into the components folder.

quicksketch’s picture

Rock! Thanks, I'll review and put in before other major changes go in.

jdblank’s picture

Sorry, as a newbie can you let me know how to apply this patch to the form module. It is exactly what I need but I am not sure how to do it.

Thanks,

Josh

quicksketch’s picture

Hi jdblank :) Welcome to Drupal. I'm sure you've noticed, all development on Drupal (both core and modules) is done through patches. Try http://drupal.org/patch/apply for learning how to use a patch, and http://drupal.org/patch/create for learning how to make them. Thanks!

jdblank’s picture

Thanks. I was able to add it no problem.

The page break inserts fine but pressing next page does not do anything. Just reloads the current page.

Josh

gribnif’s picture

jdblank, are you using Drupal 5.x? This patch will not work with 4.x.

jdblank’s picture

Yes 5.x

gribnif’s picture

Is there any chance you're testing this with an anonymous user, with cookies turned off? I haven't tried, but that might cause what you're seeing.

If that's not the reason, then I'm stumped as to what it could be. Diagnosing it would unfortunately be rather difficult. We might have to wait for others to have the same problem.

jdblank’s picture

i was testing with anonymous but cookies were on.

quicksketch’s picture

Status: Needs review » Fixed

Works awesome for me. Applied with no problems. I've committed this enhancement to the 5.x development version. Let's work out any kinks in a new issue. Thanks so much Gribnif!

Anonymous’s picture

Status: Fixed » Closed (fixed)