Drupal Association members fund grants that make connections all over the world.
Drupal 6's Forms API is great, but its AHAH support (a technique similar to AJAX) is lacking. You have to write a menu callback for every AHAH-enabled form item of your form. This is time consuming, hard to maintain and hard to write tests for. Not to mention that the code for those menu callbacks is not easy to understand, yet always the same. ("What's that piece of code for?" – "I'm not sure, it's just necessary…") See my blog post about this if you want more details: http://wimleers.com/blog/ahah-helper-module.
Notes about version 2
Version 2 of this module simplifies the usage a lot and contains a much improved example. My blog post is slightly outdated: in version 2, the
#first_time property no longer exists: it was too cumbersome to use. Instead, validation is only performed when a button is pressed, not when an AHAH event fires because of a changed select, for example. See this issue for details.
It allows you to:
- not write any menu callback at all.
- have a sole, central form definition function that has some if-tests to support a changing form based on the user's input, i.e. by checking
$form_state['storage']. This is in fact the exact same system you've been applying if you've already written multi-step forms. This makes sense, because AHAH forms are in fact normal multi-step forms, that just happen to be updatable through AHAH as well.
You still have to use the
#ahahproperty and set a wrapper, but you provide a "magical path" that will automatically rebuild and render the desired part of the form. If the part of the form that you want to be rendered is
$form['fapi']['rocks']then you would do
'path' => ahah_helper_path(array('fapi', 'rocks'))and that's it.
Adding graceful degradation just became really easy: just create buttons with the appropriate text, set
- skip form validation for all AHAH updates that do not call validate or submit callbacks.
- have new AHAH-powered form items added in an AHAH callback (previously not supported).
Look at the included ahah_helper_demo module for an example.
Dries Buytaert & Benjamin Schrauwen of Mollom.
- Maintenance status: Seeking co-maintainer(s)
- Development status: Maintenance fixes only
- Reported installs: 676 sites currently report using this module. View usage statistics.
- Downloads: 24,430
- Last modified: December 2, 2014
- Stable releases are covered by the security advisory policy.
Look for the shield icon below.