Fix: Properly sort language and country select by users locale

Enh: Allow search in country profile field dropdown
This commit is contained in:
Lucas Bartholemy 2017-06-10 18:56:43 +02:00
parent 3b227af3ff
commit 9681319c97
4 changed files with 66 additions and 38 deletions

View File

@ -219,6 +219,10 @@ class HForm extends \yii\base\Component
$options['label'] = $definition['label'];
}
if (isset($definition['htmlOptions']) && is_array($definition['htmlOptions'])) {
$options = array_merge($options, $definition['htmlOptions']);
}
$showLabel = !isset($definition['label']) || $definition['label'] !== false;
if (isset($definition['type'])) {

View File

@ -28,6 +28,9 @@ HumHub Change Log
- Fixed #2560: Markdown profile field editable flag not working
- Fix: Hide also header (space, profile) counts when following system is disabled
- Fix: Perma link to space contents broken when space homepage was changed
- Fix: Properly sort language and country select by users locale
- Enh: Allow search in country profile field dropdown
1.2.0 (April 16, 2017)
--------------------------------

View File

@ -120,7 +120,12 @@ class AccountController extends BaseAccountController
return $this->redirect(['edit-settings']);
}
return $this->render('editSettings', array('model' => $model, 'languages' => Yii::$app->i18n->getAllowedLanguages()));
// Sort countries list based on user language
$languages = Yii::$app->i18n->getAllowedLanguages();
$col = new \Collator(Yii::$app->language);
$col->asort($languages);
return $this->render('editSettings', array('model' => $model, 'languages' => $languages));
}
/**

View File

@ -5,6 +5,7 @@
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\user\models\fieldtype;
use humhub\modules\user\models\User;
@ -69,6 +70,10 @@ class CountrySelect extends Select
}
}
// Sort countries list based on user language
$col = new \Collator(Yii::$app->language);
$col->asort($items);
return $items;
}
@ -91,4 +96,15 @@ class CountrySelect extends Select
return $value;
}
/**
* @inheritdoc
*/
public function getFieldFormDefinition()
{
$definition = parent::getFieldFormDefinition();
$definition[$this->profileField->internal_name]['htmlOptions'] = ['data-ui-select2' => true];
return $definition;
}
}