. . .

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 9, 2010

DropDown for pageSize in CGridView

A convenient drop down to select page size and save in User state. Step 1: On top of my controller action for the gridview (if you used CRUD, this is actionAdmin() ) i added: // page size drop down changed if (isset($_GET['pageSize'])) { Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']); unset($_GET['pageSize']); // would interfere with pager and […]
October 8, 2010

Steps required to change project to production mode

Step 1: In config/main.php, add following element to "components" array 'cache'=>array( 'class'=>'system.caching.CApcCache', ),   Step2: In config/main.php, add following element to " components[‘db’] " array 'schemaCachingDuration' => 3600   Step 3: Comment out the following line of index.php defined('YII_DEBUG') or define('YII_DEBUG',true);   Step 4: Replace following line in index.php $yii=dirname(__FILE__).'/../yii/framework/yii.php'; […]
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, […]
October 4, 2010

Ajax button in CGridView

To add an ajax button to CGridView modify the buttons column  as   'columns' => array( 'id', 'name', array( 'class'=>'CButtonColumn', 'template' => '{view} {update} {delete}', 'buttons'=>array( 'view' => array( 'url'=>'"index.php?r=admin/view&id=".$data->user_id."&m=users"', 'click' => "function (){ $('#viewTab').load($(this).attr('href'));return false; }" ) ), ), )  

  • Cost Efficient Solutions.
  • Minimal Timelines.
  • Effective Communication.
  • High Quality Standards.
  • Lifetime Support.
  • Transparent Execution.
  • 24/7 Availability.
  • Scalable Teams.

Join Our 200+ Happy Clients Across Globe


Free Consultation.

    Do you need tech. help of your startup/business? Experts from our team will get in touch with you.

    Please do not post jobs/internships inquiries here.