3

I'm new to Drupal, but I want to create an add-on. The add-on requires some sort of multi-page form with advanced jQuery (I already looked at the jQuery module). The add-on requires details of the current logged in user and will also communicate with an external database.

I've been looking at tutorials concerning Module creation etc. But they mostly cover creation of simple forms, where as what I want to create is more of a plugin.

4 Answers 4

4

Multi page forms are a total drag. Pro Drupal Development, has a very good section on this topic, and I highly recommend that book if you are doing any Drupal development.

Online I found the following article pretty useful too (though I ultimately went with my own system).

http://www.nicklewis.org/using-chaos-tools-form-wizard-build-multistep-forms-drupal-6

1
  • 2
    I was about to recommend the Pro Drupal Development chapter on the form API, which has a great multi-page form tutorial I think the book, updated for Drupal v7, is about to come out.
    – Ted
    Dec 12, 2010 at 19:46
1

There's a decent example here: http://thedrupalblog.com/creating-multipage-form-using-forms-api

To make the most out of this, you're going to want to get pretty friendly with the Form API: http://drupal.org/node/204270

Sadly Drupal.org seems to be missing a Drupal 6.x explanation (though plenty exist for 5.x and 4.7 oddly enough).

2
  • Isn't there a way to link a 'normal' PHP script? I was looking to use the jQuery jEditable plugin (appelsiini.net/projects/jeditable), combined with a variable number of inputfields. This doesn't seem to be an easy trick in combination with drupal...
    – user485659
    Dec 11, 2010 at 22:01
  • Not really. The benefit working with Drupal's tools (i.e. forms) is that when you install a module in the future that - for example - modifies all your form fields, your custom development will reap the same benefits as the rest of the site. I think you'll find most things can be accomplished with a combination of custom modules and the theme layer (which lets you get pretty close to running plain PHP).
    – Dominic
    Dec 11, 2010 at 23:35
0

Multi step forms are complex by nature, but there are some methods to make it easier. I recommend that you have a look at the multistep form tools offered by the Ctools module. This blog post by Nick Lewis explains how you can use it.

I think you should think twice before going with javascript/jQuery to create your forms. Javascript is a great way to improve the user interface, but it can be easily manipulated because it's client side technology. You shouldn't rely on javascript alone for things like input validation, temporary storage of form values and controlling the flow between different steps of the form.

0

I feel odd saying this, but I don't think you want to use the Drupal Forms API.

The Forms API provides a lot of security features (unique token, rebuilds form after submit to compare to ensure correct form is processed, etc.) and allows other modules to modify your forms, but I think a lot of those features will get in the way of your jEditable form. Multi-page forms are not that challenging using the Forms API, but jEditable elements will be.

Your module could simply add a menu item with a page callback function that puts together your jEditable form for you. That is about as close to the world of a 'normal PHP' script as Drupal will let you get.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.