ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE/branches/prj/framework/cakephp/app/controllers/diaries_controller.php @ 5061

Last change on this file since 5061 was 5061, checked in by ebihara, 15 years ago

#1843:バリデーションのサンプルとしてDiaryモデルの追加

File size: 681 bytes
Line 
1<?php
2class DiariesController extends AppController
3{
4    var $name = 'Diaries';
5    var $uses = array('Diary');
6
7    function view($id)
8    {
9        $diary = $this->Diary->findById($id);
10        $this->set('diary', $diary);
11        $this->pageTitle = $diary['Diary']['subject'];
12    }
13
14    function add()
15    {
16        if ($this->Diary->create($this->data) && $this->Diary->validates()) {
17            $data = $this->data;
18            $data['Diary']['member_id'] = $this->you['Member']['id'];
19            $this->Diary->save($data);
20            $this->redirect('/diaries/view/' . $this->Diary->getLastInsertID());
21        }
22        $this->pageTitle = '日記を書く';
23    }
24}
25?>
Note: See TracBrowser for help on using the repository browser.