public static function getInstance($id = NULL) { $form = new UserForm(); if ($id) { $user = User::model()->findByPk($id); if ($user) { $form->attributes = $user->attributes; $form->unsetAttributes(array('password')); $form->_userModel = $user; } } return $form; }