提出時のフォーム(newreports.php)は、テーブルに保存するだけでなく、隠しデータ(それぞれ7列の27レコード)をBelongsToテーブルに保存する必要があります。 id、user_id、reports_id、count、area、area_id、commentsの7つのカラムがあります。 Areaは0〜26の値で事前入力する必要があり、reports_idはall(100)で同じにする必要があります。 User_idは、フォームエントリから事前に入力する必要があります。また、IDは自動入力される必要があります。私はこれが私のコントローラのnewreports()関数で実行できると思います。cakePHPの複数のテーブルに保存する方法BelongsTo?
このような配列を記述する必要がありますか、または単純化された方法がありますか?
$this->Report->saveAll(
Array
(
[Report] => Array
(
[0] => Array
(
[id] => //leave blank because it will auto-fill?
[user_id] => //dynamically from form input
[reports_id] => //dynamically from form input
[area_id] => //dynamically from form input
[area] => 0
[count] => // this should be blank as there are no counts yet
[comments] => // this should be blank as there are no comments yet
)
[1] => Array
(
[id] => //leave blank because it will auto-fill?
[user_id] => //dynamically from form input
[reports_id] => //dynamically from form input
[area_id] => //dynamically from form input
[area] => 1
[count] => // this should be blank as there are no counts yet
[comments] => // this should be blank as there are no comments yet
)
)
)
それをやったことを、この配列は、フォームの入力からではありませんまたそれのためのビューがあります。それは隠されています。私は人々がそれを見ることを望んでいません。私はそれをバックグラウンドで実行する必要があります、自動入力またはデータベーステーブルを事前に入力して、このデータを編集できるビューにユーザーをリダイレクトします。そこには、いくつかの動的に割り当てられた静的な値と、dbに保存または挿入する必要があるものが含まれています。現在、これは私のコントローラにあります。この配列は$ dataにどのように割り当てられますか? – sloga