当前位置: 首页>>代码示例>>PHP>>正文


PHP select2\Select2类代码示例

本文整理汇总了PHP中kartik\select2\Select2的典型用法代码示例。如果您正苦于以下问题:PHP Select2类的具体用法?PHP Select2怎么用?PHP Select2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Select2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $out = '';
     $countryDropdown = Select2::widget(['name' => 'country', 'value' => '', 'data' => Country::dropdown(), 'options' => ['label' => 'yaya', 'placeholder' => 'Select Country ...', 'id' => 'country-selection']]);
     $locationDropdown = $this->form->field($this->model, 'location_id')->label(false)->widget(DepDrop::classname(), ['type' => DepDrop::TYPE_SELECT2, 'options' => ['id' => 'location-selection'], 'select2Options' => ['pluginOptions' => ['allowClear' => TRUE]], 'pluginOptions' => ['depends' => ['country-selection'], 'placeholder' => 'Select Location', 'url' => Url::to(['/location/admin/load'])]]);
     $this->_printField($countryDropdown, $out);
     $this->_printField($locationDropdown, $out);
     return $out;
 }
开发者ID:Humanized,项目名称:yii2-location,代码行数:9,代码来源:LocationSelector.php

示例2: init

 /**
  *
  */
 public function init()
 {
     if (empty($this->parentName)) {
         throw new InvalidParamException('RelativeSelect2 $parentName must be set!');
     }
     if (empty($this->url)) {
         throw new InvalidParamException('RelativeSelect2 $url must be set!');
     }
     if ($this->parentModel instanceof Model) {
         $this->options['data']['select2-parent-name'] = Html::getInputName($this->parentModel, $this->parentName);
     } else {
         $this->options['data']['select2-parent-name'] = $this->hasModel() ? Html::getInputName($this->model, $this->parentName) : $this->parentName;
     }
     if (is_array($this->url)) {
         $this->url = Url::to($this->url);
     }
     $this->options['data']['select2-url'] = $this->url;
     if (!empty($this->model) && isset($this->model->{$this->attribute})) {
         if (is_array($this->model->{$this->attribute})) {
             $this->options['data']['select2-selected-items'] = implode(',', $this->model->{$this->attribute});
         } else {
             $this->options['data']['select2-selected-items'] = $this->model->{$this->attribute};
         }
     } else {
         $this->options['data']['select2-selected-items'] = $this->value;
     }
     parent::init();
     RelativeSelect2Asset::register($this->getView());
 }
开发者ID:platx,项目名称:yii2-relative-select2,代码行数:32,代码来源:RelativeSelect2.php

示例3: renderDropDownList

 private function renderDropDownList($data, $value = null)
 {
     if (!count($data)) {
         return;
     }
     return Select2::widget(['id' => md5(Html::getInputId($this->model, $this->attribute) . mt_rand(0, 999999999) . mt_rand(0, 999999999)), 'name' => '', 'value' => $value, 'data' => array_merge([0 => '...'], $data), 'language' => 'ru']);
 }
开发者ID:ejen,项目名称:yii2-fias,代码行数:7,代码来源:FiasSelector.php

示例4: init

 public function init()
 {
     $this->setDefaultOptions();
     if ($this->getSelect2Type() == 'ajax') {
         $this->setAjaxOptions();
     }
     parent::init();
 }
开发者ID:nagser,项目名称:base,代码行数:8,代码来源:Select2.php

示例5: run

 public function run()
 {
     $variantsList = $this->field->variants;
     $variantsList = ArrayHelper::map($variantsList, 'id', 'value');
     $variantsList[0] = '-';
     ksort($variantsList);
     $checked = $this->model->getFieldVariantId($this->field->slug);
     $select = Select2::widget(['name' => 'choice-field-value', 'value' => $checked, 'data' => $variantsList, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите значение ...'], 'pluginOptions' => ['allowClear' => true]]);
     $variants = Html::tag('div', $select, $this->options);
     return $variants;
 }
开发者ID:pistol88,项目名称:yii2-field,代码行数:11,代码来源:Select.php

示例6: run

    /** Render widget */
    public function run()
    {
        $m = new $this->model_name();
        $data = $m->allAsArray;
        // Without model and implementing a multiple select
        if ($this->title != '') {
            echo '<label class="control-label">' . $this->title . '</label>';
        }
        echo \kartik\select2\Select2::widget(['name' => $this->behavior->post_name, 'data' => $data, 'value' => $this->model->relatedIdsArray, 'options' => ['placeholder' => $this->placeholder, 'multiple' => true, 'sorter' => 'function(data) {
									return data.sort();
								}']]);
    }
开发者ID:porcelanosa,项目名称:yii2-related,代码行数:13,代码来源:RelatedWidget.php

示例7: selectField

 function selectField($attribute, $data, $widgetOptions = [], $fieldOptions = [])
 {
     $defaultFieldOptions = ['options' => ['class' => 'form-group']];
     $defaultInputOptions = ['class' => 'form-control select', 'placeholder' => $this->model->getAttributeLabel($attribute) . '...'];
     $fieldOptions = array_replace_recursive($defaultFieldOptions, $fieldOptions);
     $inputOptions = array_replace_recursive($defaultInputOptions, isset($widgetOptions['inputOptions']) ? $widgetOptions['inputOptions'] : []);
     if ($this->viewMode || in_array($attribute, $this->disabledFields)) {
         $fieldOptions['enableClientValidation'] = false;
         $inputOptions['disabled'] = 'disabled';
     }
     $defaultWidgetOptions = ['data' => $data, 'options' => $inputOptions, 'pluginOptions' => ['allowClear' => true, 'minimumResultsForSearch' => 1]];
     $widgetOptions = array_replace_recursive($defaultWidgetOptions, $widgetOptions);
     return $this->form->field($this->model, $attribute, $fieldOptions)->widget(Select2::classname(), $widgetOptions);
 }
开发者ID:michael-vostrikov,项目名称:books-test,代码行数:14,代码来源:Render.php

示例8: init

 /**
  * @inherit doc
  * @throw InvalidConfigException
  */
 public function init()
 {
     if (empty($this->pluginOptions['url'])) {
         throw new InvalidConfigException("The 'pluginOptions[\"url\"]' property has not been set.");
     }
     if (empty($this->pluginOptions['depends']) || !is_array($this->pluginOptions['depends'])) {
         throw new InvalidConfigException("The 'pluginOptions[\"depends\"]' property must be set and must be an array of dependent dropdown element ID.");
     }
     if (empty($this->options['class'])) {
         $this->options['class'] = 'form-control';
     }
     if ($this->type === self::TYPE_SELECT2) {
         Config::checkDependency('select2\\Select2', 'yii2-widget-select2', 'for dependent dropdown for TYPE_SELECT2');
     }
     parent::init();
     if ($this->type !== self::TYPE_SELECT2 && !empty($this->options['placeholder'])) {
         $this->data = ['' => $this->options['placeholder']] + $this->data;
     }
     if ($this->type === self::TYPE_SELECT2 && (!empty($this->options['placeholder']) || !empty($this->select2Options['options']['placeholder']))) {
         $this->pluginOptions['placeholder'] = '';
     } elseif ($this->type === self::TYPE_SELECT2 && !empty($this->pluginOptions['placeholder']) && $this->pluginOptions['placeholder'] !== false) {
         $this->options['placeholder'] = $this->pluginOptions['placeholder'];
         $this->pluginOptions['placeholder'] = '';
     }
     $this->_view = $this->getView();
     $this->registerAssets();
     if ($this->type === self::TYPE_SELECT2) {
         if (empty($this->data)) {
             $this->data = ['' => ''];
         }
         if ($this->hasModel()) {
             $settings = ArrayHelper::merge($this->select2Options, ['model' => $this->model, 'attribute' => $this->attribute, 'data' => $this->data, 'options' => $this->options]);
         } else {
             $settings = ArrayHelper::merge($this->select2Options, ['name' => $this->name, 'value' => $this->value, 'data' => $this->data, 'options' => $this->options]);
         }
         echo Select2::widget($settings);
         $id = 'jQuery("#' . $this->options['id'] . '")';
         $text = ArrayHelper::getValue($this->pluginOptions, 'loadingText', 'Loading ...');
         $this->_view->registerJs("{$id}.on('depdrop.beforeChange',function(e,i,v){{$id}.select2('data',{text: '{$text}'});});");
         $this->_view->registerJs("{$id}.on('depdrop.change',function(e,i,v,c){{$id}.select2('val',{$id}.val());});");
     } else {
         echo $this->getInput(!empty($this->typename) ? $this->typename : 'dropdownList', true);
     }
 }
开发者ID:eugene-kei,项目名称:yii2-micro-school-crm,代码行数:48,代码来源:DepDrop.php

示例9: run

 public function run()
 {
     $variantsList = $this->filter->variants;
     $variantsList = ArrayHelper::map($variantsList, 'id', 'value');
     $variantsList[0] = '-';
     ksort($variantsList);
     $checked = false;
     foreach ($variantsList as $variantId => $value) {
         if ($this->model->checkedId($variantId)) {
             $checked = $variantId;
             break;
         }
     }
     $select = Select2::widget(['name' => 'choise-option', 'value' => $checked, 'data' => $variantsList, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите значение ...'], 'pluginOptions' => ['allowClear' => true]]);
     $variants = Html::tag('div', $select, $this->options);
     $new = [];
     $new[] = Html::input('text', 'variant_value', '', ['placeholder' => 'Новый вариант', 'data-filter-id' => $this->filter->id, 'data-create-action' => Url::toRoute(['/filter/filter-variant/create']), 'class' => ' form-control']);
     $new[] = Html::button(Html::tag('i', '', ['class' => 'glyphicon glyphicon-plus']), ['class' => 'btn btn-success']);
     $variants .= Html::tag('div', implode('', $new), ['class' => 'new-variant']);
     return $variants;
 }
开发者ID:oakcms,项目名称:oakcms,代码行数:21,代码来源:Select.php

示例10: registerAssets

 /**
  * Registers the needed assets
  */
 public function registerAssets()
 {
     $view = $this->getView();
     DepDropAsset::register($view);
     DepDropExtAsset::register($view);
     $this->registerPlugin('depdrop');
     if ($this->type === self::TYPE_SELECT2) {
         $loading = ArrayHelper::getValue($this->pluginOptions, 'loadingText', 'Loading ...');
         $this->select2Options['data'] = $this->data;
         $this->select2Options['options'] = $this->options;
         if ($this->hasModel()) {
             $settings = ArrayHelper::merge($this->select2Options, ['model' => $this->model, 'attribute' => $this->attribute]);
         } else {
             $settings = ArrayHelper::merge($this->select2Options, ['name' => $this->name, 'value' => $this->value]);
         }
         echo Select2::widget($settings);
         $id = $this->options['id'];
         $view->registerJs("initDepdropS2('{$id}','{$loading}');");
     } else {
         echo $this->getInput('dropdownList', true);
     }
 }
开发者ID:dieos2,项目名称:bolaoyyi2,代码行数:25,代码来源:DepDrop.php

示例11: widgetSendMessageModal

    /**
     * @param $view View
     * @return string
     * @throws \Exception
     */
    public static function widgetSendMessageModal(&$view)
    {
        $view->registerJs("messageurl = '" . Url::to(['/users/send-message'], true) . "';");
        ob_start();
        Modal::begin(['header' => '<h3>' . Yii::t('app', 'Send Message') . '</h3>', 'id' => 'messagemodal', 'size' => 'modal-md', 'closeButton' => ['label' => '', 'class' => 'close glyphicon glyphicon-remove'], 'options' => ['tabindex' => false], 'footer' => '<button type="button" class="btn btn-default pull-right" data-dismiss="modal">' . Yii::t('app', 'Cancel') . '</button>' . '<button  type="button" class="btn btn-primary pull-left" id="sendBtn">' . Yii::t('app', 'Send') . '</button>']);
        $url = \yii\helpers\Url::to(['/users/search']);
        echo Select2::widget(['options' => ['placeholder' => 'To:'], 'model' => new \app\models\User(), 'theme' => Select2::THEME_KRAJEE, 'name' => 'receiver_id', 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => $url, 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function(city) { return city.text; }'), 'templateSelection' => new JsExpression('function (city) { return city.text; }')]]);
        $Message = Yii::t('app', 'Message');
        $placeholder = Yii::t('app', 'Enter you message..');
        echo <<<HTML

<div style="margin:20px 0 25px 0;">
    <div class="form-group">
        <label for="comment">{$Message} :</label>
        <textarea placeholder="{$placeholder}" class="form-control" rows="5" id="message" style="max-width:100%;"></textarea>
    </div>
</div>


HTML;
        Modal::end();
        return ob_get_clean();
    }
开发者ID:abutouq,项目名称:video,代码行数:28,代码来源:MessageHelper.php

示例12:

echo $form->field($model, 'id')->textInput(['disabled' => 'disabled', 'placeholder' => 'autonumber']);
?>
					<?php 
echo $form->field($model, 'number')->textInput(['maxlength' => true]);
?>
					<?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
					<?php 
echo $form->field($model, 'city_id')->widget(DepDrop::classname(), ['data' => [], 'type' => DepDrop::TYPE_SELECT2, 'select2Options' => ['pluginOptions' => ['multiple' => FALSE, 'allowClear' => TRUE, 'tags' => TRUE, 'maximumInputLength' => 255]], 'pluginOptions' => ['initialize' => TRUE, 'placeholder' => 'Select or type city', 'depends' => ['rgndistrictform-province_id'], 'url' => Url::to(['/rgn-city/depdrop-options', 'selected' => $model->city_id]), 'loadingText' => 'Loading cities ...']]);
?>
					<?php 
echo $form->field($model, 'province_id')->widget(DepDrop::classname(), ['data' => [], 'type' => DepDrop::TYPE_SELECT2, 'select2Options' => ['pluginOptions' => ['multiple' => FALSE, 'allowClear' => TRUE, 'tags' => TRUE, 'maximumInputLength' => 255]], 'pluginOptions' => ['initialize' => TRUE, 'placeholder' => 'Select or type province', 'depends' => ['rgndistrictform-country_id'], 'url' => Url::to(['/rgn-province/depdrop-options', 'selected' => $model->province_id]), 'loadingText' => 'Loading provinces ...']]);
?>
					<?php 
echo $form->field($model, 'country_id')->widget(Select2::classname(), ['data' => RgnCountry::asOption(), 'pluginOptions' => ['placeholder' => 'Select or type Country', 'multiple' => FALSE, 'allowClear' => TRUE, 'tags' => TRUE, 'maximumInputLength' => 255]]);
?>
                </p>

				<?php 
$this->endBlock();
?>

				<?php 
echo Tabs::widget(['encodeLabels' => false, 'items' => [['label' => 'RgnDistrict', 'content' => $this->blocks['main'], 'active' => true]]]);
?>
                <hr/>
				<?php 
echo $form->errorSummary($model);
?>
				<?php 
开发者ID:AlvaCorp,项目名称:yii2-boilerplate,代码行数:31,代码来源:_form.php

示例13:

    

	
    <div class="row">
        <div class="col-lg-6 col-xs-6">
            <?php 
echo $form->field($model, 'category_id')->widget(Select2::classname(), ['data' => Category::buildTextTree(), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите категорию ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
            
            <?php 
echo $form->field($model, 'producer_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Producer::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите бренд ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
        <div class="col-lg-6 col-xs-6">
            <?php 
echo $form->field($model, 'category_ids')->label('Прочие категории')->widget(Select2::classname(), ['data' => Category::buildTextTree(), 'language' => 'ru', 'options' => ['multiple' => true, 'placeholder' => 'Доп. категории ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
    </div>

    <?php 
echo $form->field($model, 'text')->widget(\yii\imperavi\Widget::className(), ['plugins' => ['fullscreen', 'fontcolor', 'video'], 'options' => ['minHeight' => 400, 'maxHeight' => 400, 'buttonSource' => true, 'imageUpload' => Url::toRoute(['tools/upload-imperavi'])]]);
?>

    <?php 
echo $form->field($model, 'short_text')->textInput(['maxlength' => true]);
?>

	<?php 
echo Gallery::widget(['model' => $model]);
?>
开发者ID:pistol88,项目名称:yii2-shop,代码行数:28,代码来源:_form.php

示例14:

$form = ActiveForm::begin(['layout' => 'horizontal']);
?>

    <div>
        <?php 
echo $form->errorSummary($model);
?>
        <?php 
$this->beginBlock('main');
?>
        <p>
            <?php 
/*= $form->field($model, 'client_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Client::find()->active()->all(), 'id', 'name'), ['prompt' => '']) */
?>
            <?php 
echo $form->field($model, 'client_id')->widget(\kartik\select2\Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(\common\models\Client::find()->active()->all(), 'id', 'name'), 'options' => ['prompt' => '']]);
?>

            <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

            <?php 
echo $form->field($model, 'email')->input('email', ['maxlength' => true]);
?>

            <?php 
echo $form->field($model, 'phone')->input('tel', ['maxlength' => true, 'placeholder' => '(10 digits only)']);
?>

            <?php 
开发者ID:jslight,项目名称:helpdesk,代码行数:31,代码来源:_form.php

示例15:

foreach ($rces as $i => $rce) {
    $ids[$i] = $rce->reserva_id;
}
$data = ArrayHelper::map(Reserva::find()->where(['not in', 'id', $ids])->all(), 'id', 'ReservaSelect');
?>

    <?php 
echo $form->field($model, "reserva_id")->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Seleccionar Reserva...', 'id' => 'reservaId'], 'pluginOptions' => ['width' => '300px', 'disabled' => !$model->isNewRecord]]);
?>

    <?php 
$data = ArrayHelper::map(Profesional::find()->all(), 'id', 'Nombres');
?>
        
        <?php 
echo $form->field($model, "persona_id_realiza_examen")->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Seleccionar Profesional que realiza el Examen...'], 'pluginOptions' => ['width' => '300px', 'disabled' => !$model->isNewRecord]]);
?>

<?php 
foreach ($modelsExamenes as $i => $modelExamen) {
    $script = <<<JS
// here you right all your javascript stuff
\$('#reservaId').change(function(){
    var reservaId = \$(this).val();

    \$.get('index.php?r=examen/get-datos-examen',{ reservaId : reservaId },function(data){
        var data = \$.parseJSON(data);
        \$('#rceexamenexamen-{$i}-monto_a_pagar').attr('value',data[{$i}].monto);
        \$('#rceexamenexamen-{$i}-descripcion').attr('value',data[{$i}].descripcion);
        \$('#rceexamenexamen-{$i}-observaciones').attr('value',data[{$i}].observaciones);
    });
开发者ID:altair141,项目名称:videoClub,代码行数:31,代码来源:_form.php


注:本文中的kartik\select2\Select2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。