protected function registerAssets() { parent::registerAssets(); $assetPath = realpath(__DIR__ . '/../assets'); $assetUrl = \Yii::app()->assetManager->publish($assetPath); \Yii::app()->clientScript->registerCssFile($assetUrl . '/select2-bootstrap.css'); }
//else $array = array(); ?> <div class="span2"><?php echo $form->labelEx($model, 'dept_id', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php echo Select2::activeMultiSelect($model, 'dept_id', CHtml::listData(Dept::model()->findAllByAttributes(array('orgid' => Yii::app()->user->getState("org_id"))), 'id', 'name'), array('select2Options' => array('width' => '65%', 'placeholder' => '--- Select Departments ---'))); ?> </div> <div class="span2"><?php echo $form->labelEx($model, 'groups', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php echo Select2::activeMultiSelect($model, 'g_id', CHtml::listData(group::model()->findAll(), 'id', 'name'), array('select2Options' => array('width' => '65%', 'placeholder' => '--- Select Groups ---'))); ?> </div> </div> </div> </tr> <tr> <div class="row"> <div class="col-md-3 col-sm-6"> <?php echo $form->hiddenField($model, 'organisation_id', array('class' => 'inline-labels', 'value' => Yii::app()->user->getState("org_id"))); ?> <div class="span2"><?php
use yii\helpers\Html; use kartik\widgets\ActiveForm; use kartik\builder\Form; /** * @var yii\web\View $this * @var yii\widgets\ActiveForm $form * @var \common\models\Osempresas $model */ $this->title = Yii::t('app', 'Seleccione Empresa'); //$this->params['breadcrumbs'][] = $this->title; ?> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4"> <div class="login-panel panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Selecciones Empresa</h3> </div> <div class="panel-body"> <?php $form = ActiveForm::begin(); echo $form->field($model, 'state_1')->widget(Select2::classname(), ['data' => array_merge(["" => ""], $data), 'options' => ['placeholder' => 'Select a state ...'], 'pluginOptions' => ['allowClear' => true]]); echo ' ' . Html::submitButton(Yii::t('app', 'Aceptar'), ['class' => 'btn btn-lg btn-primary btn-block', 'name' => 'login-button']); ActiveForm::end(); ?> </div> </div> </div> </div> </div>
?> </div> <div class="span2"><span class="label label-info"> Default : All Departments Selected</span></div> </div> </div> </tr> <br/> <tr> <div class="row"> <div class="col-md-3 col-sm-6"> <div class="span2"><?php echo $form->labelEx($model, 'fileNames', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php echo Select2::activeMultiSelect($model, 'fileNames', array(), array('select2Options' => array('width' => '85%', 'placeholder' => '--- Select File Names ---'))); ?> </div> <div class="span2"><span class="label label-info"> Default : All Files Selected</span></div> </div> </div> </tr> <br/> </table> <div style="text-align: center;"> <?php echo CHtml::submitButton('Print', array('submit' => array('label/showLabel')), array('color' => TbHtml::BUTTON_COLOR_SUCCESS, 'size' => TbHtml::BUTTON_SIZE_DEFAULT)); ?>
/** * Gets the JavaScript paths associated with the widget. * * @return array An array of JavaScript paths */ public function getJavascripts() { return Select2::addJavascripts($this->getOption('culture')); }
?> <?php echo $form->field($model, 'number'); ?> <?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'abbreviation'); ?> <?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]]); ?> <div class="form-group"> <?php echo Html::submitButton('Search', ['class' => 'btn btn-primary']); echo Html::resetButton('Reset', ['class' => 'btn btn-default']); ?> </div> <?php ActiveForm::end(); ?> </div>
<?php echo $form->errorSummary($model); ?> <?php echo $form->field($model, 'name'); ?> <?php $models = Acctype::find()->All(); //array('order' => 'name') //$list = \yii\helpers\ArrayHelper::map($models, 'id', 'name'); //$options = array("class" => 'span5', 'id' => ucfirst($this->id) . '_AccType_id'); //$select = \yii\helpers\Html::dropDownList(ucfirst($this->id) . '[AccType_id]', 0, $list, $options); echo $form->field($model, 'AccType_id')->widget(Select2::className(), ['data' => \yii\helpers\ArrayHelper::map($models, 'id', 'name')]); ?> <?php //echo $form->field($model,'AccType_id',array('class'=>'span5')); if (isset($items)) { $this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('app', 'Add new'), 'type' => 'success', 'options' => array('onclick' => '$("#addnew").dialog("open"); return false;'))); echo app\widgets\GridView::widget(array('id' => 'acc-templateItem-grid', 'dataProvider' => $items->search(), 'filter' => $items, 'columns' => array(array('attribute' => 'eavFields_id', 'value' => '$data->EavFields->name'), array('class' => 'yii\\grid\\ActionColumn', 'template' => '{remove}', 'buttons' => array('remove' => array('label' => '<i class="glyphicon glyphicon-remove"></i>', 'url' => '$data->id', 'options' => array('onclick' => 'deleteTempItm(this);return false;'))))))); } ?> <div class="form-actions">
$subchild->name = $subchild->getparent->name . "->" . $subchild->name; $rootLevelCats = array_merge($rootLevelCats, $child->childs); } } $rootobj = new Category(); $rootobj->id = 0; $rootobj->name = "-----"; $root = array($rootobj); $rootLevelCats = array_merge($root, $rootLevelCats); if (isset($model->id) && $model->id == 1) { echo "This is the root node and can't be moved."; $model->pid = 0; } else { //if(isset($_GET['categorypid'])) //{ echo Select2::activeMultiSelect($model, 'categories', CHtml::listData($rootLevelCats, 'id', 'name'), array('required' => 'required', 'select2Options' => array('width' => '85%', 'placeholder' => '--- Add Categories ---'))); echo CHtml::ajaxLink(Yii::t('category', TbHtml::button('+', array('color' => TbHtml::BUTTON_COLOR_SUCCESS, 'size' => TbHtml::BUTTON_SIZE_DEFAULT))), $this->createUrl('category/addnew'), array('onclick' => '$("#divDialog").dialog("open"); return false;', 'update' => '#divDialog'), array('id' => uniqid())); ?> <div id="divDialog"></div> <?php /*else { echo Select2::activeMultiSelect($model,'categories', CHtml::listData($rootLevelCats, 'id', 'name'),array( 'required' => 'required', 'select2Options' => array( 'placeholder' => '--- Add Categories ---'))); ?> <?php echo CHtml::ajaxLink(Yii::t('category',TbHtml::button('+',array( 'color' => TbHtml::BUTTON_COLOR_SUCCESS, 'size'=>TbHtml::BUTTON_SIZE_DEFAULT, ))),$this->createUrl('category/addnew'),array(
/** * Get default widget class based on input field type * @param string $type * @return string */ public static function getWidgetClassNameFromFieldType($type) { switch ($type) { case self::INPUT_DATE: $widgetClass = DatePicker::className(); break; case self::INPUT_DATETIME: $widgetClass = DateTimePicker::className(); break; case self::INPUT_COLOR: $widgetClass = ColorInput::className(); break; case self::INPUT_SELECT2_MULTI: case self::INPUT_SELECT2_TAGS: case self::INPUT_SELECT2: $widgetClass = Select2::className(); break; case self::INPUT_SELECT_PICKER: case self::INPUT_SELECT_PICKER_MULTI: $widgetClass = BootstrapSelect::className(); break; case self::INPUT_EDITOR_CK: $widgetClass = CKEditor::className(); break; case self::INPUT_EDITOR_BS_WYSIHTML5: $widgetClass = BootstrapWysihtml5::className(); break; case self::INPUT_EDITOR_BS_SUMMERNOTE: $widgetClass = BootstrapSummernote::className(); break; default: $widgetClass = ''; break; } return $widgetClass; }
?> <?php echo $form->textField($model, 'idCompra', array('class' => 'form-control', 'size' => 20, 'maxlength' => 20)); ?> <?php echo $form->error($model, 'idCompra'); ?> </div> <div class="form-group"> <?php echo $form->labelEx($model, 'idComercial'); ?> <?php echo Select2::activeDropDownList($model, "idComercial", CHtml::listData($listPdv, 'idComercial', function ($model) { return "{$model->idComercial} - {$model->nombrePuntoDeVenta}"; }), array('prompt' => 'Seleccione punto de venta', 'style' => 'width=100%;display:block;')); ?> <?php echo $form->error($model, 'idComercial'); ?> </div> <?php echo CHtml::submitButton('Borrar Remision', array('class' => "btn btn-default")); ?> <?php $this->endWidget(); ?>
$this->renderPartial('/pedido/_saldosPDV', array('respuesta' => $objCompra->getSaldosPDV())); ?> </div> </div> <hr> <div> <span class="title"><strong>Asignar Punto de venta</strong></span> <form action="/callcenter/index/generardoccruce/" method="post" id="asignarpdv" name="asignarpdv"> <div class="row"> <div class="col-md-9"> <?php echo Select2::dropDownList('select-pdv-asignar', $objCompra->idComercial, CHtml::listData($listPdv, 'idComercial', function ($model) { return "{$model->idComercial} - {$model->nombrePuntoDeVenta}"; }), array('prompt' => 'Seleccione punto de venta', 'id' => 'select-pdv-asignar', 'style' => 'width: 100%;')); ?> </div> <div class="col-md-3"> <button type="button" id="<?php echo uniqid(); ?> " data-compra="<?php echo $objCompra->idCompra; ?> " data-action="asignar-pdv" style="color: #dd4814;" class="btn btn-sm"><strong>Asignar</strong></button> </div> </div> <input type="hidden" value="386414" id="idPedido" name="idPedido"> <input type="hidden" value="pdv" id="opcion" name="opcion">
</div> </div> </div> </tr> <?php if ($chosenId == 1) { } else { if ($chosenId == 2) { echo "<tr>\n <div class='row'>\n <div class='col-md-3 col-sm-6'>\n <div class='span2'>"; echo $form->labelEx($model, 'block_group', array('class' => 'inline-labels')); echo "</div>\n <div class='span3'>"; echo Select2::activeMultiSelect($model, 'block_group', CHtml::listData(Group::model()->findAll(), 'id', 'name'), array('select2Options' => array('placeholder' => 'Select Groups', 'width' => '85%'))); echo "</div>\n </div>\n </div>\n </tr>\n <tr>\n <div class='row'>\n <div class='col-md-3 col-sm-6'>\n <div class='span2'>"; echo $form->labelEx($model, 'block_user', array('class' => 'inline-labels')); echo "</div>\n <div class='span3'>"; echo Select2::activeMultiSelect($model, 'block_user', CHtml::listData(User::model()->findAll(), 'id', 'name'), array('select2Options' => array('placeholder' => 'Select Users', 'width' => '85%'))); echo "</div>\n </div>\n </div>\n </tr>"; } } ?> </table> <div style="text-align: center;"> <?php echo "<br/>"; ?> <?php echo TbHtml::submitButton($model->isNewRecord ? 'Submit' : 'Update', array('color' => TbHtml::BUTTON_COLOR_SUCCESS, 'size' => TbHtml::BUTTON_SIZE_DEFAULT)); ?> <?php echo TbHtml::button('Cancel', array('color' => TbHtml::BUTTON_COLOR_DANGER, 'size' => TbHtml::BUTTON_SIZE_DEFAULT, 'onclick' => 'history.go(-1)'));
https://github.com/kartik-v/yii2-widget-select2 <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'titulo', ['attribute' => 'categoria_id', 'value' => 'categoria.categoria', 'format' => 'raw', 'filter' => Select2::widget(['model' => $searchModel, 'attribute' => 'categoria_id', 'data' => \yii\helpers\ArrayHelper::map(\app\models\Categoria::find()->all(), 'id', 'categoria'), 'options' => ['placeholder' => 'Seleccione...'], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'created_by', 'value' => 'createdBy.name'], ['class' => 'yii\\grid\\ActionColumn']]]); ?> --------------------------------------------------------------------------------------------------------------------------- public function rules() { return [ [['created_by', 'updated_by'], 'safe'], ]; } ...validate()... $query->joinWith('createdBy'); ->andFilterWhere(['like', 'user.name', $this->created_by])
<!--<?php echo $form->field($model, 'podr', ['template' => "{label}<div class=\"col-sm-8\">{input}</div>\n{hint}\n<div class=\"col-sm-offset-4 col-lg-8\">{error}</div>", 'labelOptions' => ['class' => 'col-sm-4 control-label'], 'inputOptions' => ['class' => 'form-control input-sm']])->widget(Select2::classname(), ['data' => $podr_data, 'options' => ['placeholder' => 'Укажите подразделения ...', 'multiple' => true], 'pluginOptions' => ['allowClear' => true, 'tags' => true, 'templateResult' => new JsExpression('function(repo) { //if (repo.loading) return repo.text; _getTree(1, 0, repo); }')]]); ?> <div class="hr-line-dashed"></div>-->
public function select2($options = []) { $this->parts['{input}'] = Select2::widget(array_merge($options, ['model' => $this->model, 'attribute' => $this->attribute])); return $this; }
<?php $form = ActiveForm::begin(['type' => ActiveForm::TYPE_HORIZONTAL, 'method' => 'post', 'id' => $model->formName(), 'enableClientValidation' => true]); ?> <div class="row"> <div class="col-sm-6"> </div> <div class="col-sm-6"> <?php echo $form->field($model, 'KD_DISTRIBUTOR')->widget(Select2::classname(), ['data' => $drop, 'options' => ['placeholder' => 'Pilih Perusahaan ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'CORP_ID')->widget(Select2::classname(), ['data' => $dropunit, 'options' => ['placeholder' => 'Pilih Perusahaan ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <?php /* if not equal to isNewRecord then dropdown status */ if (!$model->isNewRecord) { echo $form->field($model, 'STATUS')->dropDownList(['' => ' -- Silahkan Pilih --', '0' => 'Tidak Aktif', '1' => 'Aktif']); } ?> <div class="form-group"> <?php
/** * Select2 demo action */ public function action_select2() { $select2 = new Select2(array("testval1" => "Test Entry #1", "testval2" => "Test Entry #2", "testval3" => "Test Entry #3"), 'testselect'); $this->renderHtml($select2->render()); }