Suppose, you place your self somewhere in the middle of Yii 1.1 experience ladder. You’re no longer new to Yii 1.1, but you’re not an experienced Yii developer in the same time. In this case, I strongly encourage you to spare half an hour or so on reading articles in Yii Wiki, that are grouped in this table-of-contents article. These articles contains a lot of useful information, a must-know for all experienced Yii developers, that are mostly not know to those with middle experience
onChange but also to
onKeyPress events. Why? There is a rare situation, where user selects value by clicking dropdown and then using keyboard’s cursor up or cursor down keys.
onKeyPress event will be fired in this situation instead of
onChange event. And desired effect won’t work, if you put it only to
onChange event handler.
You can use
CActiveRecord::populateRecord method in Yii to create new record basing on existing one. And, as this descriptions means, you must use it like that:
$data = $this->getUser($id); $model = new Users; $model = $model->populateRecord($data, FALSE);
instead of (last line):
populateRecord creates new model instead of modifying existing one!