本文整理匯總了PHP中kartik\widgets\Select2::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP Select2::init方法的具體用法?PHP Select2::init怎麽用?PHP Select2::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kartik\widgets\Select2
的用法示例。
在下文中一共展示了Select2::init方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
public function init()
{
$this->pluginOptions = array_merge($this->defaultAjaxOptions(), (array) $this->pluginOptions);
if ($this->url) {
$this->pluginOptions['ajax']['url'] = $this->url;
}
$this->pluginOptions['minimumInputLength'] = $this->minLength;
$this->pluginOptions['initSelection'] = $this->getInitSelectionJs();
$this->pluginOptions['ajax']['data'] = new JsExpression('function(term,page) { return {term:term}; }');
$this->pluginOptions['ajax']['results'] = new JsExpression('function(data,page) { return {results:data}; }');
parent::init();
}
示例2: init
public function init()
{
if ($this->placeholder_from_label) {
$placeholder = $this->model->getAttributeLabel($this->attribute);
} else {
$placeholder = $this->placeholder ?: __('Select a tags...');
}
$this->options = ['placeholder' => $placeholder];
$attribute = $this->attribute;
$this->attribute = $attribute . 'Str';
$models = Tag::find()->{$attribute}()->all();
$tags = [];
foreach ($models as $model) {
$tags[] = $model->name;
}
$this->pluginOptions = ['tags' => $tags, 'tokenSeparators' => [',', ';'], 'maximumInputLength' => 64, 'allowClear' => true];
parent::init();
}