FAPI

AJAX-ifying Drupal Node Forms

Recently, for the first time with Drupal 6, I needed to create a form where a variable number of fields could be added to it by simply clicking a 'Add more' button. I wanted to design a node form where users could create a custom compilation album of their favourite tracks. However the number of tracks would vary from album to album and so I wanted a way for users to be able to add more fields to the form without reloading the page. Now, yes I could have used CCK to build this custom content type, but I wanted to see how this could be done using Drupal's FAPI alone.

Multi-step Node Forms in Drupal 6

Recently I needed a create a multi-step node form in Drupal 6. Unlike other forms in Drupal, it wasn't as simple as configuring a new submit handler that sets $form_state['rebuild'] to TRUE. After trying a few different ways and a bit of searching, I found the solution. The trick is to hide the 'submit' button and use hook_form_alter() on the 'preview' button to regenerate the form for step 2. However, this is probably best explained with some sample code to illustrate.

Technical Tuesdays: #theme Form Elements into tables

Forms API (FAPI) is one of the coolest pieces of Drupal. The power and flexibility of hook_form_alter has made it possible to change the behavior of a module, without actually modifying any code in the original module, and has created a whole new class of "helper" modules that enhance the capabilities of existing modules. But this article isn't about form_alter.
Syndicate content