--- /dev/null
+/**
+ * Implements hook_forms().
+ */
+function {{ machine_name }}_forms($form_id, $args) {
+ // Simply reroute the (non-existing) $form_id 'mymodule_first_form' to
+ // 'mymodule_main_form'.
+ $forms['mymodule_first_form'] = array(
+ 'callback' => 'mymodule_main_form',
+ );
+
+ // Reroute the $form_id and prepend an additional argument that gets passed to
+ // the 'mymodule_main_form' form builder function.
+ $forms['mymodule_second_form'] = array(
+ 'callback' => 'mymodule_main_form',
+ 'callback arguments' => array('some parameter'),
+ );
+
+ // Reroute the $form_id, but invoke the form builder function
+ // 'mymodule_main_form_wrapper' first, so we can prepopulate the $form array
+ // that is passed to the actual form builder 'mymodule_main_form'.
+ $forms['mymodule_wrapped_form'] = array(
+ 'callback' => 'mymodule_main_form',
+ 'wrapper_callback' => 'mymodule_main_form_wrapper',
+ );
+
+ // Build a form with a static class callback.
+ $forms['mymodule_class_generated_form'] = array(
+ // This will call: MyClass::generateMainForm().
+ 'callback' => array('MyClass', 'generateMainForm'),
+ // The base_form_id is required when the callback is a static function in
+ // a class. This can also be used to keep newer code backwards compatible.
+ 'base_form_id' => 'mymodule_main_form',
+ );
+
+ return $forms;
+}