Класс:
Код: Выделить всё
class Test extends CActiveRecord{
public $test;
public static function model($className=__CLASS__){
return parent::model($className);
}
public function tableName(){
return '{{'.strtolower(get_class($this)).'}}';
}
protected function afterFind(){
$this->test='123';
}
public function rules(){
return array(
array('name, test', 'length', 'max'=>255),
);
}
}
Код: Выделить всё
class TestForm extends CFormModel{
public $name;
public $test;
public function rules(){
return array(
array('name, test', 'length', 'max'=>255)
);
}
}
Код: Выделить всё
$rcd=Test::model()->findByPk(1);
$model=new TestForm();
$model->setAttributes($rcd->attributes);
// в $model присвоились только id и name