I am adding a submit handler to the drupal commerce submit form:

module_load_include('inc', 'my_module', 'cim_profile');
$form['buttons']['continue']['#submit'][] = 'my_module_create_cim_profile';

The submit handler is located in a .inc file. I assumed that the code above would load the .inc file to be used by the submit, but that doesn't seem to be the case, I keep getting an error that the file isn't found. When I tested the module include with

 $inc = module_load_include('inc', 'my_module', 'cim_profile');

it did print out the path to the .inc file, so I know it was located.

How can I load my .inc in so that it is available for the submit handler?

1 Answer 1


You want form_load_include() instead:

Ensures an include file is loaded whenever the form is processed.


Use this function instead of module_load_include() from inside a form constructor or any form processing logic as it ensures that the include file is loaded whenever the form is processed. In contrast to using module_load_include() directly, form_load_include() makes sure the include file is correctly loaded also if the form is cached.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.