<legend id='G6CIn'><style id='G6CIn'><dir id='G6CIn'><q id='G6CIn'></q></dir></style></legend>

    <tfoot id='G6CIn'></tfoot>

      <bdo id='G6CIn'></bdo><ul id='G6CIn'></ul>
  • <small id='G6CIn'></small><noframes id='G6CIn'>

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

        Drupal 6:form_state 值在提交时为空

        Drupal 6: form_state values empty on submit(Drupal 6:form_state 值在提交时为空)
      1. <legend id='5pGup'><style id='5pGup'><dir id='5pGup'><q id='5pGup'></q></dir></style></legend>

        <i id='5pGup'><tr id='5pGup'><dt id='5pGup'><q id='5pGup'><span id='5pGup'><b id='5pGup'><form id='5pGup'><ins id='5pGup'></ins><ul id='5pGup'></ul><sub id='5pGup'></sub></form><legend id='5pGup'></legend><bdo id='5pGup'><pre id='5pGup'><center id='5pGup'></center></pre></bdo></b><th id='5pGup'></th></span></q></dt></tr></i><div id='5pGup'><tfoot id='5pGup'></tfoot><dl id='5pGup'><fieldset id='5pGup'></fieldset></dl></div>
            1. <small id='5pGup'></small><noframes id='5pGup'>

                • <bdo id='5pGup'></bdo><ul id='5pGup'></ul>
                  <tfoot id='5pGup'></tfoot>
                    <tbody id='5pGup'></tbody>

                  本文介绍了Drupal 6:form_state 值在提交时为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 Drupal 6 中创建一个自定义表单,下面的代码似乎一切正常,包括提交时在数据库中创建了一个新条目,但所有 $form_state 值都是空的.我错过了什么?

                  I'm trying to create a custom form in Drupal 6 and everything seems to work okay with the code below including when submitted a new entry is created in the database however all the $form_state values are empty. What am I missing?

                  <?php
                  function rate_form($form_state) {
                    $form = array();
                    $form['rate']['name'] = array(
                      '#type' => 'textfield',
                      '#title' => t('Name'),
                      '#size' => 30,
                      '#maxlength' => 100,
                      '#required' => TRUE,
                    );
                    $form['rate']['description'] = array(
                      '#type' => 'textarea',
                      '#title' => t('blah, blah'),
                      '#maxlength' => 1500,
                    );
                    $form['rate']['submit'] = array('#type' => 'submit', '#value' => t('Rate!'));
                    return $form;
                  }
                  
                  print drupal_get_form($form_id);
                  
                  function rate_form_submit($form_id, &$form_state) {
                    db_query("INSERT INTO {rate_comments} (name, description) VALUES ('%s', '%s')", $form_state['values']['rate']['name'], $form_state['values']['rate']['description']);
                    drupal_set_message(t('Thank you! Your rating has been added.'));
                  }
                  ?>
                  

                  推荐答案

                  除非你指定,$form_state['values'] 将是一个平面数组而不是一个嵌套数组,所以值将位于:

                  Unless you specify it, $form_state['values'] will be a flat array and not a nested one so the values will be located at:

                  $form_state['values']['name']
                  $form_state['values']['description']
                  

                  您可以很容易地使用 devel 模块自行调试此问题.有了那个主动你可以做

                  You could have debugged this problem yourself pretty easily using the devel module. With that active you could do

                  function rate_form_submit($form_id, &$form_state) {
                      dpm($form_state);
                      //db_query("INSERT INTO {rate_comments} (name, description) VALUES ('%s', '%s')", $form_state['values']['rate']['name'], $form_state['values']['rate']['description']);
                      drupal_set_message(t('Thank you! Your rating has been added.'));
                  }
                  

                  dpm 是 devel 定义的一个函数,它创建了一个很好的变量可视化表示,您可以在其中单击以显示/隐藏数组和类对象中的值.使用该信息,您可以确定所需值的存储位置.在您想在运行时检查变量的情况下,这是一个很好的工具.

                  dpm is a function that devel has defined, it creates a nice visual representation of the variable, where you click to show/hide the values inside arrays and class objects. Using that info you would have been able to fine where the values you needed was stored. It's a great tool in situations like this, where you want to inspect variables at runtime.

                  这篇关于Drupal 6:form_state 值在提交时为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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

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

                      <tfoot id='lrvnw'></tfoot>
                        • <bdo id='lrvnw'></bdo><ul id='lrvnw'></ul>
                            <legend id='lrvnw'><style id='lrvnw'><dir id='lrvnw'><q id='lrvnw'></q></dir></style></legend>