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 ($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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With