I have an external form that needs to be loaded inside a template file, used by a block. Right now, i’m a bit confused as to how to load this .inc. Looking at the API docs point to module_load_include() which I’ve tried with no luck (see example 1, from the template file):
module_load_include('inc', 'example2'); print(render(drupal_get_form("example2_form"))); //Form method in inc file is called "example2_form();
The actual form method is just a few settings for now, once I prove this works…
function example2_form($form, $form_state) { $form['fname'] = array( '#type' => 'textfield', "#attributes" => array( 'placeholder' => t("First Name"), ), ); $form['#validate'][] = "example2_form_validate"; $form['#submit'][] = "example2_form_submit"; return $form; }
I figure the cleanest approach (besides figuring out what could cause the .inc to not load here) is to just drop the form code into the .module, and load the Form array in the blocks hook_block_view().
However, I like to keep stuff clean, so if there’s something I’m overlooking here, or how to best do this, it would be cool to know.
File name for the form include is example2.form.inc.