現在の状態
Cakephp3の環境にてフォームを作成しております。
フォーム内で、下記のように記述しています。
最終的に、フォームをDBへ保存する方法がわからず。初歩的な内容で恐縮なのですが、
検索方法がわからずご教授いただければ幸いです。
<h2>サンプルアンケート</h2> <table id="tesuid"> <tbody> <tr data-row="1"> <th class="form_ttl">項目1</th> <td class="required_none"> <div class="input_wrap"> <?= $this->Form->text('sample1',['id' => 'date4_1', 'class' => 'inputdate', 'readonly' => "readonly"]); ?> </div> </td> <th class="form_ttl">項目2</th> <td class="required_none"> <div class="input_wrap"> <?= $this->Form->text('sample2',['label' => false], ['required' => true]); ?> </div> </td> <th class="form_ttl">項目3</th> <td class="required_none"> <div class="input_wrap"> <?= $this->Form->text('sample13', ['label' => false], ['required' => true]); ?> </div> </td> <td class="required_none"> <div class="input_wrap"> <?= $this->Form->button('削除', ['class'=>'btnDelete', 'name' => 'confirm','type' => 'button','value' => 1]) ?> </div> </td> </tr> </tbody> </table> <input type="button" value="追加" id="btnAdd"> <article> <div class="btnarea_center"> <?= $this->Form->button('登録', ['class'=>'btn_', 'name' => 'confirm','type' => 'submit','value' => 1]) ?> </div> </article>
jQuery
1<?= $this->Html->scriptStart(['block' => true]) ?> 2 3jQuery(function($) { 4 $("#btnAdd").on("click", function() { 5 $("#tesuid tbody tr:last-child").clone(true).appendTo("#tesuid tbody"); 6 $("#tesuid tbody tr:last-child input").val(""); 7 // idに付与するための行番号を取得 8 row = parseInt($("#tesuid tbody tr:last-child").attr("data-row"))+1; 9 // 行番号を更新 10 $("#tesuid tbody tr:last-child").attr("data-row", row); 11 // カレンダーフォームにidを設定 12 $("#tesuid tbody tr:last-child input.inputdate").attr("id", "date4_"+row); 13 // カレンダーイベントの再設定 14 $("#date4_"+row).removeClass("hasDatepicker").off("focusin").on("focusin", function(e) { 15 $(this).datepicker(); 16 }); 17 // 行削除 18 $(".btnDelete").on("click", function() { 19 $(this).parents("tr").remove(); }); 20 21 }); 22 $(".inputdate").datepicker(); 23}); 24 25<?= $this->Html->scriptEnd() ?> 26
現在の画面を元にやりたいこと
現在、無事に削除や、項目の追加は完了できたのですが、最終的に複製したデータをデータベースへ格納する方法がわからず、ご教授いただけますと幸いです。
あなたの回答
tips
プレビュー