Comparison of Form Building Modules

Drupal has a lot of modules aimed at helping site builders and users add forms to their sites. What follows is a rough comparison of three of them for Drupal 8 and five of them for Drupal 7. Please add any missed or new information about the ones listed.

Using form_alter to change the default value of a date

If you need to set a default value for an exposed views filter, you can do it like this:

this example code will set a ranged date to have a default value of -30 days for the start date, and today for the end date

Multi-step forms

<< mforms project page

Installation and configuration

Mforms is a library, so by itself it does not provide any functionality (besides the real-life examples in the mforms example module). Therefore there is no configuration or installation besides enabling the module in the module list.

Basic usage

Included module mforms_example contains several real life examples that are documented in code. To find out what it does visit /mforms page after you enable mforms_example module.

Mforms architecture

For faster dive into mforms here is the basic architecture:


STORE_KEY - not just identifies the storage slot for submitted values, it represents the identifier of whole multi-step form implementation.

Steps file - The file where individual form steps with their validate and submit callbacks reside. See mforms_example/mforms/ for demonstration. This file must be named in the following pattern: and placed in "mforms" directory of the module in which you are implementing the multi step form.

Store object - MformsIstore implementation responsible for storing submitted values and internal mforms data needed to control the stepping process.

Drupal 6 Form API Quickstart Guide

Note that these instructions focus on Drupal 6. Corresponding documentation for Drupal 7 is here.

The Drupal Form API provides sophisticated form techniques and also allows for almost unlimited possibilities for custom theming, validation, and execution of forms. Even better, ANY form (even those in core) can be altered in almost any way imaginable—elements can be removed, added, and rearranged.

Creating Custom Elements

Drupal's Form API (FAPI) makes it possible to create custom types of form elements if the standard ones (such as textfield or checkbox) are not enough for your application. Here's how to declare and use them. You may find the Form Workflow Illustration helpful here. In this example we use $element instead of $form in places where only the element's portion of the form is available, just to make it more clear what you have to work with.

Subscribe with RSS Subscribe to RSS - form api