2
編集することはできませんので、のようなものです:CakePHPの2.0:コントローラ内の配列データ(ポストからは)私は、コントローラ内の単純なCRUDアプリケーション、 と編集ページを持っている
function admin_edit($id = null) {
if (empty($this->data)) {
$this->data = $this->Product->read(); //product is the model
} else {
//its a post request, and $this->data is populated
debug($this->data);
//i force the id to another id
$this->data["Product"]["id"] = 115;
debug($this->data); //the data remains the same, doesnt change.. why?
//i will save this later
}
}
どちらのデバッグは、このの結果:
前
Array
(
[Product] => Array
(
[id] => 8
[alias] => ME
[order] => 80
[open_close_images] => 1
[gallery_id] => 8
[video_id] => 2
)
)
後:
Array
(
[Product] => Array
(
[id] => 8 //it must be 115 now!!
[alias] => ME
[order] => 80
[open_close_images] => 1
[gallery_id] => 8
[video_id] => 2
)
)
これはなぜですか?
cakephp 1.3ではうまくいきましたが、どのようにしてその配列を「ロック」することができるのか分かりません。 (再)このように、モデルのID VARを設定することで、IDを設定
は大丈夫そうそれがポイントということではありませんそのモデルのより複雑な関連データを変更する必要があるので、私はオブジェクトでそれを取得するとは思わない。申し訳ありませんが、私はその権利を説明していない場合 – apelliciari
@avastregああ、まあ実際にあなたの質問から完全にはっきりしていなかった。上記の私の更新答えを見てください。 – Oldskool
thx!一方、もっと深い検索で私はこれが本当に問題だったhttp://stackoverflow.com/questions/8203445/cakephp-2-request-data-and-modelを見つけました! – apelliciari