私はケーキブックを読んでいましたが、それでも理解できませんでした。データベースへのデータの追加に問題があるので、基本的な追加機能の結果を確認したいと思います。
public function add() {
if ($this->request->is('post')) {
$this->Ficha->create();
if ($this->Ficha->save($this->request->data)) {
$this->Session->setFlash('Your post has been saved.');
//$last_id=$this->Ficha->getLastInsertID();
$this->redirect(array('action' => 'preencher_ficha'),$last_id);
} else {
$this->Session->setFlash('Unable to add your post.');
}
print_r($this->Ficha->save);
}
}
add.ctpファイル
<?php
echo $this->Form->create('Ficha', array('action' => 'index'));
echo $this->Form->input('cod_produto', array('label' => 'Código Produto:'));
echo $this->Form->input('nome_produto', array('label' => 'Nome Produto:'));
echo $this->Form->input('versao', array('label' => 'Versão:'));
echo $this->Form->input('data_ficha', array('label' => 'Data:'));
//echo $this->Form->input('body', array('rows' => '3'));
echo $this->Form->end('Criar Ficha');
?>
そのために、$debugまたは$print_rを使用して、フォームを送信した後、cakephpが問題の場所を示しますが、正しく使用していないか、間違った「セクション」で使用している可能性があります。誰かが私が印刷するためにどの変数を使うべきか、そしてスクリーンにadd関数の結果を印刷するためにその出力の変数の()の間に何を持っているべきか教えてもらえますか?
ありがとうございました!