Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 多个表单-一个提交按钮_Html_Cakephp - Fatal编程技术网

Html 多个表单-一个提交按钮

Html 多个表单-一个提交按钮,html,cakephp,Html,Cakephp,我在cakephp做一个调查。这是我第一次使用cakephp,我偶然发现了一个问题,所以我需要一些建议。我想有多个回答(单选按钮),最后只有一个提交按钮 我正在用FormHelper制作一个表单,我的问题是:我必须在数据库中输入每个问题,然后用cakephp获取它吗?或者可以把它放在我的HTML中,然后用cakephp添加答案选项 这就是我现在拥有的(单选按钮的HTML+cakephp) 但当我尝试输入多个答案选项+问题时,我得到了以下结果: 我的代码: <div class="que

我在cakephp做一个调查。这是我第一次使用cakephp,我偶然发现了一个问题,所以我需要一些建议。我想有多个回答(单选按钮),最后只有一个提交按钮

我正在用FormHelper制作一个表单,我的问题是:我必须在数据库中输入每个问题,然后用cakephp获取它吗?或者可以把它放在我的HTML中,然后用cakephp添加答案选项

这就是我现在拥有的(单选按钮的HTML+cakephp)

但当我尝试输入多个答案选项+问题时,我得到了以下结果:

我的代码:

<div class="question">

<div class="number">
            <p>1</p>
</div>

<div class="questionI">
            <p>The organization’s mission/purpose is absolutely clear</p>
</div>

<div class="answers">

            <?php

            echo $this->Form->create();
            $options = array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10' );
            $attributes = array('legend' => false);
            echo $this->Form->radio('answer1', $options, $attributes);
            echo $this->Form->radio('answer2', $options, $attributes);
            echo $this->Form->end('Submit');
            ?>
</div>

</div>

一,

本组织的使命/宗旨是绝对明确的

我的第二个问题是在另一个问题组中,所以我知道我不能以这种方式将它们对齐。。
我本来想做一个for each循环,但是我想我必须把每个问题都放到我的数据库中?

你应该在顶部创建表单,在末尾关闭表单,并为问题创建一个类似表格的结构。 比如:


1.

组织的使命/宗旨是绝对明确的

2.

公司的使命/宗旨让我觉得我的工作很重要,我为成为公司的一员感到自豪


您不需要在同一位置输出所有表单部件,只要它位于表单内部即可

谢谢!当你解释它时,它看起来很简单:D
<?php echo $this->Form->create();
      $options = array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10' );
      $attributes = array('legend' => false);?>

<div class="question question-1">
    <div class="number">1</div>
    <p class="questionI">The organization’s mission/purpose is absolutely clear</p>
    <div class="answer">
        <?php echo $this->Form->radio('answer1', $options, $attributes);?>
    </div>
</div>

<div class="question question-2">
    <div class="number">2</div>
    <p class="questionI">The organization’s mission/purpose makes me feel that my job is important, and I’m proud to be part of this organization</p>
    <div class="answer">
        <?php echo $this->Form->radio('answer2', $options, $attributes);?>
    </div>
</div>

<?php echo $this->Form->end('Submit');?>