如何渲染作为可渲染数组的一部分的表单?
在 .module
/**
* Implements hook_block_view();
*/
function bibdk_vejviser_block_view($delta = '') {
switch ($delta) {
case 'bibdk_vejviser':
$block['title'] = t('Find Library');
$block['content'] = array(
'link' => array(
'#type' => 'link',
'#title' => t("Find library"),
'#href' => 'http://example.org',
),
'form' => drupal_get_form('bibdk_vejviser_form'),
);
break;
}
return $block;
}
在自定义块 .tpl
// This will work (renders both elements)
print $content;
// This will also work (renders link)
print render($elements['link']);
// This will NOT work (renders nothing)
print render($elements['form']);
我究竟做错了什么?
更新:如果我将 drupal_get_form() 包装在一个数组中,它会起作用。这是为什么??
...
'form' => array(drupal_get_form('bibdk_vejviser_form')),
...