更新时间:2022-12-22 17:40:04
drupal_get_form
的返回实际上是一个渲染数组本身,所以你可以这样做:
The return from drupal_get_form
is actually a render array itself so you could just do this:
$f = drupal_get_form('example_module_form', $node);
$f['#weight'] = 1;
$node->content['data_collection_form'] = $f;
如果您确实想以其他方式执行此操作,尽管表单应该是可渲染的元素",因此键不应以 #
为前缀:
If you do want to do it the other way though the form should be a renderable 'element', so the key shouldn't be prefixed by #
:
$f = drupal_get_form('example_module_form', $node);
$node->content['data_collection_form'] = array(0 => $f, '#weight' => 1);
渲染数组中以 #
为前缀的键的所有条目都被视为属性,而不被视为子项"并递归渲染.
All entries in a render array with a key prefixed with #
are considered properties, while those that aren't are considered 'children' and are recursively rendered.