2 * Implements hook_forms().
4 function {{ machine_name }}_forms($form_id, $args) {
5 // Simply reroute the (non-existing) $form_id 'mymodule_first_form' to
6 // 'mymodule_main_form'.
7 $forms['mymodule_first_form'] = array(
8 'callback' => 'mymodule_main_form',
11 // Reroute the $form_id and prepend an additional argument that gets passed to
12 // the 'mymodule_main_form' form builder function.
13 $forms['mymodule_second_form'] = array(
14 'callback' => 'mymodule_main_form',
15 'callback arguments' => array('some parameter'),
18 // Reroute the $form_id, but invoke the form builder function
19 // 'mymodule_main_form_wrapper' first, so we can prepopulate the $form array
20 // that is passed to the actual form builder 'mymodule_main_form'.
21 $forms['mymodule_wrapped_form'] = array(
22 'callback' => 'mymodule_main_form',
23 'wrapper_callback' => 'mymodule_main_form_wrapper',
26 // Build a form with a static class callback.
27 $forms['mymodule_class_generated_form'] = array(
28 // This will call: MyClass::generateMainForm().
29 'callback' => array('MyClass', 'generateMainForm'),
30 // The base_form_id is required when the callback is a static function in
31 // a class. This can also be used to keep newer code backwards compatible.
32 'base_form_id' => 'mymodule_main_form',