I am using the examples.modules "form examples #10" to create a multistep form.

When using only 2 steps, it works nicely, as in the example.

But I would like to see a form with 3 steps, or instruction on how to modify the code to create more than two steps.

We might also add information about form_state.

Comments

rfay’s picture

I agree -

The D7 version may be more fleshed out, but I'd like to make these both completely generic as a nice extensible framework for multistep.

rfay’s picture

Version: 6.x-1.x-dev »
Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new8.4 KB

Starting with a Drupal 7 wizard example that is extensible.

coltrane’s picture

Randy and I discussed this at DrupalCamp Colorado and I'm all for a framework for multi-step forms.

I've looked through the patch but I'll apply it and provide a more thorough comment. (consider this a subscribe and a +1 :)

coltrane’s picture

Status: Needs review » Needs work

Randy and I talked about this today on irc. I was against a sequential method with integers at first, but it really is a great way to start working with multistep. So +1! Some minor things:

+++ form_example/form_example.info
@@ -7,4 +7,5 @@ files[] = form_example.module
+files[] = form_example_multistep.inc

The file is form_example_wizard.inc, right?

+++ form_example/form_example_wizard.inc
@@ -0,0 +1,188 @@
+ * Estensible wizard form example.

minor, but it's "extensible"

ilo’s picture

Assigned: Unassigned » ilo

Thanks coltrane, I've fixed that, and also this other minor:

  $form['aunts_name'] = array(
    '#type' => 'textfield',
    '#title' => t("Your first cousin's aunt's Social Security number"),

cousin's aunt's Social number? lol.. too confusing to even guess the name, ('aunts_name' is the field).. Randy patches are always that fun!!

I'm trying to figure out how to write tests for this..

ilo’s picture

Status: Needs work » Needs review
StatusFileSize
new14.38 KB

I've documented most of the functions and their usage, including tips like 'you are not required to change this function'..

I've splitted _submit to next_submit and left a final _submit hook to do all the processing, this way next and previous buttons have their own specific handlers that 'are not required to be changed'.

Wizard steps are defined out of the form builder, now it looks eassier to understand what the user needs to touch and what is 'not required to be changed'.

Including some tests, but they need a lot of love.

and also fixed the issue detected by coltrane

ilo’s picture

bumping again to top.

rfay’s picture

Issue tags: -Needs tests
StatusFileSize
new15.9 KB

Wow, ilo - thanks for the great work on this. It was significantly improved by what you did.

This patch has:

  • Minor fixups to comments.
  • Since the semantics of #limit_validation_errors changed (you can no longer preserve unvalidated values in $form_state['values']) I updated the comments around that.
  • That passing of $form_state['values'] by reference on the caller was just wrong. Something slept in though the fingers. That's a warning in 5.2 as well. Don't know why I haven't seen it.
  • Added to the test to cover the entire workflow. I think these tests are adequate.
ilo’s picture

coltrane, feel free to mark as rtbc if you think the mutilform example now is what you have expected.

Thanks for the review and the changes, rfay!

ilo’s picture

#8: form_example_wizard_867224_08.patch queued for re-testing.

ilo’s picture

Status: Needs review » Reviewed & tested by the community

so.. It is ready.

rfay’s picture

Assigned: ilo » Unassigned
Status: Reviewed & tested by the community » Fixed

Committed to HEAD: http://drupal.org/cvs?commit=436176

Perhaps we should try this in D6 as well.

ilo’s picture

Version: » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)

I don't know if D6 an D7 form examples are similar or this requires a major rewrite, but I'm in favour of having a D6 example with the same layout, options, forms and whatever as in D7 to easy its mainteinance.

mile23’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (won't fix)

It's end-of-life time for the 6.x-1.x branch of Examples. See #2642596: D6, D7 Roadmap for Examples