Monthly Archives: May 2012

Yii Add validation for selected fields

On Controller file $model = new Model_Name(); $model->setScenario(‘Articlereview’); $model->field_name = $_POST[‘fname’]; $model->save(); echo CHtml::errorSummary($model); On Model Files Under rule array array(‘field name list’, ‘required’,’on’ => ‘Articlereview’), Advertisements

Posted in Yii-php | Leave a comment

Add condition on model

Add condition in Model. public function relations() { return array( ANY_Name => array(self::MANY_MANY,MODEL_NAME) // this is for common ANY_Name => array(self::MANY_MANY,MODEL_NAME, ‘on’=>’ANY_Name.fied_name = 1’) // this is for conditional } }

Posted in Yii-php | Leave a comment