Skip to content

Instantly share code, notes, and snippets.

@ismakv
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismakv/9ae9f566d27ed4642e43 to your computer and use it in GitHub Desktop.
Save ismakv/9ae9f566d27ed4642e43 to your computer and use it in GitHub Desktop.
yii2 sort with multilanguage behaivour
$query = Shop::find()->multilingual();
$query->joinWith(['translations']);
//echo '<pre>', var_dump($query), '</pre>';die;
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$dataProvider->sort->attributes['title'] = [
'asc' => ['shopLang.title' => SORT_ASC],
'desc' => ['shopLang.title' => SORT_DESC],
'label'=> Yii::t('shop', 'Title')
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment