Dear community,
I am creating a module using D7, and I want to display a form in a block with some custom theming. Here is what I have for the functions in foo_module.module (skipped the parts that I think do not matter for my issue).
function foo_module_theme($existing, $type, $theme, $path) {
return array(
'foo_login' => array(
'variables' => array('form' => NULL),
),
);
}
function foo_module_block_view($delta = '') {
$block = array();
switch ($delta) {
case "login":
$form = drupal_get_form('foo_login_form');
$block["subject"] = "Login";
$block["content"] = $form;
break;
}
return $block;
}
function theme_foo_login_form($variables) {
$form = $variables['form'];
// Some custom theming
$output = drupal_render_children($form);
return $output;
}
function foo_login_form($form, &$form_state) {
$form['foo_username'] = array(
'#type' => 'textfield',
'#size' => '15',
'#id' => 'foo_username'
);
$form['foo_password'] = array(
'#type' => 'password',
'#size' => '15',
'#id' => 'foo_password'
);
$form['#theme'] = 'foo_login_form';
return $form;
}
I am getting "Invalid argument supplied for foreach() in element_children() (line .... in .../common.inc)", And the form is not displayed at all.