Saya telah buat tutorial EBook Bazet. Masalah saya ialah pada scaffolding untuk change user password .
<?php
//blog/controllers/user_controller.php
class UserController extends AppController {
var $name = 'User';
//var $scaffold;
var $scaffold = 'admin'; //scaffold just for admin
function beforeRender() {
//inherit AppController beforeRender()
parent::beforeRender();
//index
if ($this->action === 'index') {
//limit the field show in index
$this->set('scaffoldFields', array('id', 'username', 'email', 'is_admin', 'created'));
}
if ($this->action === 'edit') {
$this->set('scaffoldFields', array('id', '1username', 'email', 'is_admin', 'created'));
}
if ($this->action === 'add') {
$this->set('scaffoldFields', array('id', '1username', 'email', 'is_admin', 'created'));
}
if ($this->action === 'view') {
$this->set('scaffoldFields', array('id', 'username', 'email', 'is_admin', 'created'));
?>Didapati untuk index dan view berfungsi dengan baik cuma add dan edit tidak berfungsi.
Harap otai2 cakePHP dapat membantu.
#zairo
saya sudah cuba
<?php
if ($this->action === 'edit') {
$this->set('scaffoldFields', array('id', 'username', 'email', 'is_admin', 'created'));
}
?>
tapi masih meleset.
Kalau 1username patutnya keluar error tapi tiada error yang keluar. Seolah2 tiada overwrite yang berlaku.
#zairo
Masalah selesai. Rupanya webroot/index.php saya berbeza dgn rakan sorang lain.
Mungkin sebab masalah versi.
Rakan saya: * @since CakePHP(tm) v 0.10.0.1076
saya: * @since CakePHP(tm) v 0.2.9
Saya dah uji dan memang perbezaan code dalam fail ini menjadi punca masalah.
Anyway, thanks. CakePHP rocks uh.
#zairo
jgn guna scaffold , cake bake all terus
ok menarik jugak cara cake bake all. TQ Bazet.
saya cuma nak cari punca masalah.
okay tadi tu silap tengok. Punca masalah pada webroot/index.php pada fungsi ini:
<?php
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
//define('CAKE_CORE_INCLUDE_PATH', '/usr/share/php'); //kod asal
define('CAKE_CORE_INCLUDE_PATH', ROOT); //kod yg berjaya
}
?>Kalau guna ROOT, boleh scaffold. Kalau guna /usr/share/php, tak boleh scaffold.
#zairo
lusername.. hehe.