How can i add my custom form to custom block in my custom module
I've made a custom Drupal module. Inside which I've created a block and a form. How can I make the form appear in the block content? Cheers.
Block Code:
function module_block($op = 'list', $delta = 0, $edit = array()) {
$block = array();
if 开发者_JAVA百科($op == "list") {
// Test
$block[0]["info"] = t('Block');
}
else if ($op == 'view') {
$block['content'] = module_function();
}
return $block;
}
// End module_block
Form Code:
function module_my_form($form_state) {
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#required' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
Cheers again for any help.
For anyone looking, change:
$block['content'] = module_function();
to
$block['content'] = drupal_get_form('module_my_form');
Cheers
精彩评论