La propiedad “tablename.title” no está definida

Yo soy Yiibie. Lo que bash hacer es subir una imagen (foto) y una entrada de ruta en la base de datos con la funcionalidad de actualización. He seguido este enlace ` http://www.yiiframework.com/wiki/349/how-to-upload-image-photo-and-path-entry-in-database-with-update-functionality/#hh0 . He seguido todo este enlace, pero recibir un error que es “Propiedad ‘Ngo.title’ no está definido” al hacer clic en el botón Enviar. Abajo está el código de lo que he estado tratando de hacer.

Este es el código para NgoController

array('index','view'), 'users'=>array('*'), ), array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions'=>array('create','update'), 'users'=>array('@'), ), array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions'=>array('admin','delete'), 'users'=>array('admin'), ), array('deny', // deny all users 'users'=>array('*'), ), ); } /** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $this->render('view',array( 'model'=>$this->loadModel($id), )); } /** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model=new Ngo; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Ngo'])) { $rnd = rand(0,9999); // generate random number between 0-9999 $model->attributes=$_POST['Ngo']; $uploadedFile=CUploadedFile::getInstance($model,'image'); $fileName = "{$rnd}-{$uploadedFile}"; // random number + file name $model->image = $fileName; if($model->save()) { $uploadedFile->saveAs(Yii::app()->basePath.'/../ngo/'.$fileName); // image will uplode to rootDirectory/ngo/ $this->redirect(array('admin')); } $this->redirect(array('view','id'=>$model->id)); } $this->render('create',array( 'model'=>$model, )); } /** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Ngo'])) { $_POST['Ngo']['image'] = $model->image; $model->attributes=$_POST['Ngo']; $uploadedFile=CUploadedFile::getInstance($model,'image'); if($model->save()) { if(!empty($uploadedFile)) // check if uploaded file is set or not { $uploadedFile->saveAs(Yii::app()->basePath.'/../ngo/'.$model->image); } $this->redirect(array('admin')); } $this->redirect(array('view','id'=>$model->id)); } $this->render('update',array( 'model'=>$model, )); } /** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if(Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } else throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); } /** * Lists all models. */ public function actionIndex() { $dataProvider=new CActiveDataProvider('Ngo'); $this->render('index',array( 'dataProvider'=>$dataProvider, )); } /** * Manages all models. */ public function actionAdmin() { $model=new Ngo('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['Ngo'])) $model->attributes=$_GET['Ngo']; $this->render('admin',array( 'model'=>$model, )); } /** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Ngo the loaded model * @throws CHttpException */ public function loadModel($id) { $model=Ngo::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; } /** * Performs the AJAX validation. * @param Ngo $model the model to be validated */ protected function performAjaxValidation($model) { if(isset($_POST['ajax']) && $_POST['ajax']==='ngo-form') { echo CActiveForm::validate($model); Yii::app()->end(); } } } 

Este es el código de vista (_form.php)

  beginWidget('bootstrap.widgets.BsActiveForm', array( 'id'=>'ngo-form', // Please note: When you enable ajax validation, make sure the corresponding // controller action is handling ajax validation correctly. // There is a call to performAjaxValidation() commented in generated controller code. // See class documentation of CActiveForm for details on this. 'enableAjaxValidation'=>false, 'htmlOptions' => array( 'enctype' => 'multipart/form-data', ), )); ?> 

Fields with * are required.

errorSummary($model); ?> textFieldControlGroup($model,'id'); ?> textFieldControlGroup($model,'Ngo_name',array('maxlength'=>45)); ?> textFieldControlGroup($model,'username',array('maxlength'=>45)); ?> passwordFieldControlGroup($model,'password',array('maxlength'=>45)); ?> textFieldControlGroup($model,'email',array('maxlength'=>45)); ?> textFieldControlGroup($model,'address',array('maxlength'=>45)); ?> textFieldControlGroup($model,'upload_doc',array('maxlength'=>45)); ?> textFieldControlGroup($model,'image',array('maxlength'=>45)); ?>
labelEx($model,'image'); ?> error($model,'image'); ?>
isNewRecord!='1') ?>
request->baseUrl.'/ngo/'.$model->image,"image",array("width"=>200)); ?>

BsHtml::BUTTON_COLOR_PRIMARY)); ?> endWidget(); ?>

y este es el código de los modelos (ngo.php)

 true), array('Ngo_name, username, password, email, address, upload_doc, image', 'length', 'max'=>45), // The following rule is used by search(). // Please remove those attributes that should not be searched. array('id, Ngo_name, username, password, email, address, upload_doc, image', 'safe', 'on'=>'search'), array('image', 'file','types'=>'jpg, gif, png', 'allowEmpty'=>true, 'on'=>'update'), array('title, image', 'length', 'max'=>255, 'on'=>'insert,update'), ); } /** * @return array relational rules. */ public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'userRateReviewNgos' => array(self::HAS_MANY, 'UserRateReviewNgo', 'Ngo_Ngo_id'), ); } /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'id' => 'ID', 'Ngo_name' => 'Ngo Name', 'username' => 'Username', 'password' => 'Password', 'email' => 'Email', 'address' => 'Address', 'upload_doc' => 'Upload Doc', 'image' => 'Image', ); } /** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->compare('Ngo_name',$this->Ngo_name,true); $criteria->compare('username',$this->username,true); $criteria->compare('password',$this->password,true); $criteria->compare('email',$this->email,true); $criteria->compare('address',$this->address,true); $criteria->compare('upload_doc',$this->upload_doc,true); $criteria->compare('image',$this->image,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); } 

}

había puesto una línea extra. simplemente elimine una línea del archivo modelo de la matriz de tablas relacionada (‘título, imagen’, ‘longitud’, ‘max’ => 255, ‘on’ => ‘insertar, actualizar’),