• <i id='PyBRq'><tr id='PyBRq'><dt id='PyBRq'><q id='PyBRq'><span id='PyBRq'><b id='PyBRq'><form id='PyBRq'><ins id='PyBRq'></ins><ul id='PyBRq'></ul><sub id='PyBRq'></sub></form><legend id='PyBRq'></legend><bdo id='PyBRq'><pre id='PyBRq'><center id='PyBRq'></center></pre></bdo></b><th id='PyBRq'></th></span></q></dt></tr></i><div id='PyBRq'><tfoot id='PyBRq'></tfoot><dl id='PyBRq'><fieldset id='PyBRq'></fieldset></dl></div>
    1. <legend id='PyBRq'><style id='PyBRq'><dir id='PyBRq'><q id='PyBRq'></q></dir></style></legend>

      <small id='PyBRq'></small><noframes id='PyBRq'>

        <bdo id='PyBRq'></bdo><ul id='PyBRq'></ul>
      <tfoot id='PyBRq'></tfoot>

        Drupal 7 hook_node_view 添加表单到节点的内容

        Drupal 7 hook_node_view add a form to the content of a node(Drupal 7 hook_node_view 添加表单到节点的内容)

        1. <tfoot id='MzjPu'></tfoot>
            <tbody id='MzjPu'></tbody>

          • <legend id='MzjPu'><style id='MzjPu'><dir id='MzjPu'><q id='MzjPu'></q></dir></style></legend>

            <small id='MzjPu'></small><noframes id='MzjPu'>

              <bdo id='MzjPu'></bdo><ul id='MzjPu'></ul>

                <i id='MzjPu'><tr id='MzjPu'><dt id='MzjPu'><q id='MzjPu'><span id='MzjPu'><b id='MzjPu'><form id='MzjPu'><ins id='MzjPu'></ins><ul id='MzjPu'></ul><sub id='MzjPu'></sub></form><legend id='MzjPu'></legend><bdo id='MzjPu'><pre id='MzjPu'><center id='MzjPu'></center></pre></bdo></b><th id='MzjPu'></th></span></q></dt></tr></i><div id='MzjPu'><tfoot id='MzjPu'></tfoot><dl id='MzjPu'><fieldset id='MzjPu'></fieldset></dl></div>

                  本文介绍了Drupal 7 hook_node_view 添加表单到节点的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  function example_module_node_view($node, $view_mode, $langcode)
                  {   
                      $f =  drupal_get_form('example_module_form', $node);
                      $node->content['data_collection_form'] = array('#value' => $f, '#weight' => 1); 
                  }
                  

                  为什么表单不显示?难道我做错了什么?正在填充表单对象.我可以做 #markup => 'Something' 并且它有效.

                  Why doesn't the form display? Am I doing something wrong? The form object is being populated. I can do #markup => 'Something' and it works.

                  推荐答案

                  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.

                  这篇关于Drupal 7 hook_node_view 添加表单到节点的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How do I pass parameters into a PHP script through a webpage?(如何通过网页将参数传递给 PHP 脚本?)
                  PHP - include a php file and also send query parameters(PHP - 包含一个 php 文件并发送查询参数)
                  Where can I read about conditionals done with quot;?quot; and quot;:quot; (colon)?(我在哪里可以阅读有关使用“?完成的条件的信息?和“:(冒号)?)
                  Accessing arrays whitout quoting the key(在不引用键的情况下访问数组)
                  What is the name for the quot;lt;lt;lt;quot; operator?(“lt;lt;lt;的名字是什么?操作员?)
                  default as first option in switch statement?(默认为 switch 语句中的第一个选项?)
                    <tbody id='93gXs'></tbody>

                  <i id='93gXs'><tr id='93gXs'><dt id='93gXs'><q id='93gXs'><span id='93gXs'><b id='93gXs'><form id='93gXs'><ins id='93gXs'></ins><ul id='93gXs'></ul><sub id='93gXs'></sub></form><legend id='93gXs'></legend><bdo id='93gXs'><pre id='93gXs'><center id='93gXs'></center></pre></bdo></b><th id='93gXs'></th></span></q></dt></tr></i><div id='93gXs'><tfoot id='93gXs'></tfoot><dl id='93gXs'><fieldset id='93gXs'></fieldset></dl></div>
                  • <tfoot id='93gXs'></tfoot>
                        <bdo id='93gXs'></bdo><ul id='93gXs'></ul>

                        <small id='93gXs'></small><noframes id='93gXs'>

                          1. <legend id='93gXs'><style id='93gXs'><dir id='93gXs'><q id='93gXs'></q></dir></style></legend>