Intro to Drupal 6 Multistep Form Domination Using Chaos Tools

The mere words "multistep form" once gave me a feeling of dread. There are several techniques (arguably hacks) that enable multistep forms in drupal 6. However, if you've ever used them, you'll know that they are a not techniques for the faint of heart.

While Merlinofchaos's multistep form wizard is not for the faint of heart either, I will say I found programming the forms to be fun. The setup takes a bit of focus, but after that, writing the steps is almost too easy.

Chaos Tool's wizard.inc is distinct:

wombat wizard
  1. See that stepper and buttons in the above image? You never will need to micromanage what step your form is on using the wizard. If you set up the form, it figures that sort of stuff out for you. Since it knows about stuff like "$step", its perfectly happy to figure out whether it should display a next, back, or finish button. I like code that works for me.
  2. Every step in a form is a distinct form_id, that has its own #submit, #validate, and(god knows what else can be done with it via form api). Within the steps, you should never need to think any harder than you would writing a simple form with a message, and an email address. Proof can be found below in the actual form arrays, and the submit functions.
  3. There are thousands of ways you can mess up a multistep form -- in a sense, the wizard lets you make your biggest mistakes in one $form_info array, while keeping the majority of the code (the formapi arrays, and form processing/validation functions) in small, easy to understand units that anyone with even intermediate formapi knowledge could work with.
  4. This wizard DOES power a number of complicated multistep forms that you may use every day - the multistep forms in panels in particular. In a way, its just the most recent chapter of Earl Miles vs. Drupal's formapi -- a saga that has gone on since version 4.7. [come to think of it, i think lullabot needs to make a feature film about that epic story]

Interested? Start Here

Here's a Live Demo of the Wombat Deployment tool I wrote that uses the wizard. Only impressive in how easily it was written, and how easily i could write a 3rd, 4th, 5th, or 20 steps following the same pattern [ the subject of future posts are hinted in a rogue modal.inc file in the download.]

To get started building multistep forms, follows these steps.

  1. Download Chaos Tools
  2. Advanced Help. If you start futzing with this, you'll want the docs merlinofchaos wrote on the wizard. They are available through this module only.
  3. My example module, the wombat tool to rule them all!
  4. check back in a few for all the corrections

The full code, and detailed doc on the $form_info array will only be made available to freaks who click the "read more" link.

top cleric declares nicklewis.org spam free

Update Actually, I think the spam is under control now. Only a few thousand that needed to be cleaned. In other news, I've sent my blog's mullah into exile.
****"

O Navicat -- how I love thee!

[img_assist|nid=1050|title=asdf|desc=|link=node|align=left|width=640|height=351]

Dear Site5: WTF is up with your file permissions behavior?!

I know yall do QA, however, you aren't testing for power users apparently. Check this out. I like to build and deploy drupal websites. Drupal websites require constant code updates, as well as test servers, so I like to use shell to move files around. However, it seems, whenever I move files around, every single files and directory gets assigned permissions 664, or 644 -- i forgot. The fix is running this command in the unix shell:

chmod -R ugo=rX,u+w ~

Content Type Madness (CTM): Symptoms, Treatment, and Prevention

[img_assist|nid=1045|title=|desc=|link=none|align=left|width=100|height=80]Content type madness is a common disease that effects drupal sites of all sizes. It is most frequently seen in drupal 5 and 6 sites, as result of content construction kit.

It is a serious, chronic disease that can result in long term damage to a site's agility, usability , and information architecture.

 

A Reproach to: "In Defense of Eye Candy"

The Time of Webdesign, alistapart.com, published an article "In Defense of Eye Candy". Yes, I agree: people like nice looking things. I'd even go as far as to say that surveys, and studies don't necessarily do justice to how biased all of us are to visually pleasing things. I also think many people aren't aware of the real reasons why they might choose design A, over B.

FYI: Looking for a Drupal Ninja Understudy

Job posting is here:
http://groups.drupal.org/node/21537

Use my contact form if interested. Austinites are given uber-priority, but currently the strongest applicants are outside of Austin.

Fleeing Twitter

I set up a twitter account today. It wasn't out of the blue, I was installing the twitter module for a client (works great btw). Yet, I'd be a liar if I denied flirting with the idea of twittering. After about 3 hours, I decided I didn't want to twitter.

I've begun a quest in finding the opposite of twitter, for I feel that quest will reward me with happiness.

Drupal Project Movers and Shakers: The D-6000

Highlight: WYSIWYG API Gets Top Spot With 97% Growth (Feb 8th - March 29th)

Ever wondered which modules' userbase was growing fastest?

With a bit of simpleXML, 2 hours of boredom, and drupal.org's usage charts, I can provide an answer. Personally I thought the results were rather interesting.

This list only includes projects that got 6000 downloads or more last week. I picked 6000, because otherwise, ubercart wouldn't show up.

A Drupal Weather Report

I had this weird idea: drupal has become so complex, with so many moving parts, that understanding the big picture is like predicting the weather. I forgot how long ago this was, but I know this would have been an accurate report:

PLANETWIDE DRUPAL REPORT [sometime in 2008]

Pages

Subscribe to Nick Lewis: The Blog RSS