簡體   English   中英

多種形式-一個提交按鈕

[英]Multiple forms - one submit button

我正在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>

我的第二個問題是在另一個問題div中,所以我知道我無法以這種方式對齊它們。.我當時在考慮為每個循環做一個,但是我想我必須將每個問題都放入數據庫中?

您應該在頂部創建表格,最后關閉表格,並具有類似表格的問題結構。 喜歡:

<?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');?>

您無需將所有表單部件都輸出到同一位置,只要它們在表單內即可

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM