Using with date_popup Form API element

Pop-up calendar widget for Date fields is not the only thing provided by the Date Popup module. It actually defines new form element first and then uses it when defines Pop-up calendar widget.

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 7 - How to Make a Simple Module with a Form and Menu Link

This guide will show you how to add a form to your website that is accessed through its own URL. This guide will go over module creation, form creation, and the menu hook function.

Creating the module structure
The first step in creating the module is to create a folder for the module. You should put this in "sites/all/modules/{name of your module}." Keep in mind that whenever I say "{name of your module}," you should insert the name of your module. For example, we will use the module directory "sites/all/modules/form_example."

Now, create two empty text files called "{name of your module}.module" and "{name of your module}.info."

These two files are required by your module. The .info file contains information about what your module does, while the .module file contains the actual code including hooks. Hooks are functions with special names that will be called by Drupal when actions occur. For example "form_example_menu()" is called when menu information is gathered. In many examples, you will see names such as "hook_menu()" or "my_theme_menu()" and in these cases "my_theme" and "hook" should be replaced by the name of your module or theme.

Build the basic module files

Here is what we will put into the file. This tells Drupal and users about your module.

core = "7.x"

Drupal 7 - HowTo: Copy the form buttons on node creation pages to the top


I have a custom content type with a lot of form elements (close to 100) and scrolling down to the bottom got a bit irritating when all you wanted to do it update or edit a node of this content type.
So I wanted to copy the form action buttons to the top (but still keep them at the bottom).

Here is how I did it:

1) Create a custom module

1a) In your sites/default/modules/ folder create a new folder CUSTOM_MODULE*

1b) Create the mandatory and CUSTOM_MODULE.module files.

1c) Fill out the file with some basic info. eg:

name = Custom node form modify module
description = Custom module to duplicate the form buttons on node creation forms and place them above the form items.
package = Custom
core = 7.x
version = 0.1

1d) Copy the following code into the CUSTOM_MODULE.module file. I'll then go through the code to explain what it does.

* Implementation of HOOK_form_alter()
function CUSTOM_MODULE_form_alter(&$form, $form_state, $form_id) {

* Copy the action buttons (submit, preview, etc ..)
* and place them at the top of the form
if(!empty($form['actions'])) {

foreach($form['actions'] as $name => $button) {



Subscribe with RSS Subscribe to RSS - form api