. . .

yii

October 10, 2010

How to customize the error message of a validation rule

The following validation rule uses an error message that is different from the default one class Post extends CActiveRecord { public function rules() { return array( array('title, content', 'required', 'message'=>'Please enter a value for {attribute}.'), // ... other rules ); } }   Source: http://www.yiiframework.com/doc/cookbook/1/
October 6, 2010

Upload and resize image using YII

Download and extract this file in protected/extensions directory.   In config/main.php file, add the following element to components array  'image'=>array( 'class'=>'application.extensions.image.CImageComponent', 'driver'=>'GD', )   Now in action, insert the following code and modify paths $model->Picture = CUploadedFile::getInstance($model,'Picture'); if( is_object($model->Picture) ) { mkdir(getcwd().'/images/users/'.$model->Id."/"); $name = getcwd().'/images/users/'.$model->Id."/".$model->Picture->getName(); $model->Picture->saveAs($name); $image = Yii::app()->image->load($name); $image->resize(50, […]