本文整理汇总了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();
}