Skip to content
Browse files

Suggest controller: user model fix

  • Loading branch information...
1 parent 7f1263d commit dc4a864ff713376301cd198d538d856378c21ce5 weavora committed
Showing with 12 additions and 6 deletions.
  1. +12 −6 controllers/SuggestController.php
View
18 controllers/SuggestController.php
@@ -4,14 +4,20 @@ class SuggestController extends Controller {
public function actionUser() {
$q = Yii::app()->request->getParam('name_startsWith');
- $userModels = call_user_func(array(User::model(), Yii::app()->getModule('message')->getSuggestMethod), $q);
+ $userModels = (array) call_user_func(array(
+ CActiveRecord::model(Yii::app()->getModule('message')->userModel),
+ Yii::app()->getModule('message')->getSuggestMethod
+ ), $q);
+
$users = array();
if ($userModels) {
- foreach ($userModels as $userModel) {
- $users[] = array(
- 'id' => $userModel->getPrimaryKey(),
- 'name' => call_user_func(array($userModel, $this->getModule()->getNameMethod))
- );
+ foreach ($userModels as $userModel) {
+ $users[] = array(
+ 'id' => $userModel->getPrimaryKey(),
+ 'name' => call_user_func(array(
+ $userModel, $this->getModule()->getNameMethod
+ ))
+ );
}
}
$json = CJSON::encode(array('users' => $users));

0 comments on commit dc4a864

Please sign in to comment.
Something went wrong with that request. Please try again.