Form hook not found through module_hook_info in module subdirectory Context:
In my Drupal 7 project, I have a module with several submodules. Because the module's root directory got crowded, I moved the submodule files to their own directories within the root.

My module's structure is like this:

mymodule
├── mymodule.info
├── mymodule.module
├── mymodule1
│   ├── mymodule1.block.inc
│   ├── mymodule1.form.inc
│   ├── mymodule1.info
│   ├── mymodule1.module
│   ├── mymodule1.page.inc
│   └── pages
│       └── foo.tpl.php
└── mymodule2
    ├── classes
    │   └── foo
    │       └── Bar.php
    ├── mymodule2.form.inc
    ├── mymodule2.info
    ├── mymodule2.install
    ├── mymodule2.module
    ├── mymodule2.page.inc
    └── pages
        ├── foo.tpl.php
        └── bar.tpl.php


Before "the big move", files that are now in the subdirectories mymodule1 and mymodule2, were located in their parent directory (the module's root directory).



The problem:
Ever since moving the files, my custom forms are not loading anymore. I have a form in mymodule1.form.inc, which used to load and render perfectly before. Now, when I use drupal_get_form() to load the form, I only get an empty form with a hidden build ID input.

Keep in the mind that the only thing that has changed here, is that the .inc files have been moved to the subdirectory, along with the module file. Also, drupal_get_path('module', 'mymodule1') returns the correct path to the module in the subdirectory.

Strangely, there are also block hooks, located in mymodule1.block.inc, which work perfectly fine, even after clearing all caches.

This is the first time I'm working with separate directories per submodule within a module. I got the inspiration from the module i18n, which uses the same construction. I searched in the Drupal documentation and the code of i18n, but could not find where I'm going wrong.

Does anyone know where I could possibly have gone wrong, or if I need to add data to mymodule1.module or mymodule1.info to make this work? Thank you.



Some details:
Caches were cleared through &lt;path to project&gt;/admin_menu/flush-cache multiple times.

I use module1_hook_info() to direct the hooks for blocks and forms to separate files. This is the return value:

array (size=9)
  'block_info' =&gt; 
    array (size=1)
      'group' =&gt; string 'block' (length=5)
  'block_configure' =&gt; 
    array (size=1)
      'group' =&gt; string 'block' (length=5)
  'block_save' =&gt; 
    array (size=1)
      'group' =&gt; string 'block' (length=5)
  'block_view' =&gt; 
    array (size=1)
      'group' =&gt; string 'block' (length=5)
  'forms' =&gt; 
    array (size=1)
      'group' =&gt; string 'form' (length=4)
  'form' =&gt; 
    array (size=1)
      'group' =&gt; string 'form' (length=4)
  'form_validate' =&gt; 
    array (size=1)
      'group' =&gt; string 'form' (length=4)
  'form_submit' =&gt; 
    array (size=1)
      'group' =&gt; string 'form' (length=4)
  'form_alter' =&gt; 
    array (size=1)
      'group' =&gt; string 'form' (length=4)


My form functions are called:


mymodule1_foobar_form
mymodule1_foobar_form_validate
mymodule1_foobar_form_submit
Thanks to Clive I found module_load_include(), which is used to load files when working with a form. I moved hook_forms() back to my main module's file and now load the mymodule1.form.inc through there, like so:

/**
 * Implements hook_forms().
 */
function mymodule1_forms($form_id, $args)
{
    module_load_include('inc', 'mymodule1', 'mymodule1.form');
    $forms = array();

    $forms['mymodule1_foo_form'] = array(
        'callback' =&gt; 'mymodule1_foo_form',
    );

    return $forms;
}


Now all my forms are loading correctly (again), over both mymodule1 and mymodule2.

The one thing I'm not sure about, that whether this could have been achieved without redundantly declaring the form callbacks to their same-named form IDs.