Example #1
3
 /**
  * Executes the widget.
  */
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeDropDownList($this->model, $this->attribute, $this->data, $this->options);
     } else {
         echo Html::dropDownList($this->name, $this->value, $this->data, $this->options);
     }
     MultiSelectAsset::register($this->view);
     $this->registerPlugin('multiSelect');
 }
Example #2
2
 public function run()
 {
     $this->registerPlugin('select2');
     Html::addCssClass($this->options, 'form-control');
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     } else {
         return Html::dropDownList($this->name, $this->selection, $this->items, $this->options);
     }
 }
Example #3
1
 public function gridRelationalColumn($attr, $arr, $key, $value)
 {
     $this->relDataArr += ArrayHelper::map($arr, $key, $value);
     return ['attribute' => $attr, 'filter' => Html::activeDropDownList($this, $attr, $this->relDataArr, ['class' => 'form-control']), 'value' => function ($model, $key, $index, $column) {
         $attr = $column->attribute;
         return $this->relDataArr[$model->{$attr}];
     }];
 }
Example #4
1
 /**
  * Renders the widget.
  */
 public function run()
 {
     if (!isset($this->options['class']) or empty($this->options['class'])) {
         $this->options['class'] = 'form-control';
     }
     $list[''] = '';
     $list += $this->list;
     echo Html::activeDropDownList($this->model, $this->attribute, $list, $this->options);
 }
Example #5
1
 /**
  * Renders the widget.
  */
 public function run()
 {
     if (!isset($this->options['class']) or empty($this->options['class'])) {
         $this->options['class'] = 'form-control';
     }
     $ages[''] = 'Chọn Mục tiêu';
     $ages += ArrayHelper::getValue(Classified::$options, 'target', []);
     echo Html::activeDropDownList($this->model, $this->attribute, $ages, $this->options);
 }
Example #6
1
 /**
  * @inheritdoc
  */
 public function renderInput($value, $attribute = null)
 {
     $select_id = Html::getInputId($this->model, $attribute ? $attribute : $this->attribute);
     $this->view->registerJs("\$('#{$select_id}').selectpicker();");
     Html::addCssClass($this->options, 'form-control');
     if (!isset($this->options['multiple'])) {
         $this->options['multiple'] = $this->multiple;
     }
     return Html::activeDropDownList($this->model, $attribute ? $attribute : $this->attribute, $this->items, $this->options);
 }
Example #7
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $timeZones = [];
     $timeZonesOutput = [];
     $now = new \DateTime('now', new \DateTimeZone('UTC'));
     foreach (\DateTimeZone::listIdentifiers(\DateTimeZone::ALL) as $timeZone) {
         $now->setTimezone(new \DateTimeZone($timeZone));
         $timeZones[] = [$now->format('P'), $timeZone];
     }
     if ($this->sortBy == static::SORT_OFFSET) {
         array_multisort($timeZones);
     }
     foreach ($timeZones as $timeZone) {
         $content = preg_replace_callback("/{\\w+}/", function ($matches) use($timeZone) {
             switch ($matches[0]) {
                 case '{name}':
                     return $timeZone[1];
                 case '{offset}':
                     return $timeZone[0];
                 default:
                     return $matches[0];
             }
         }, $this->template);
         $timeZonesOutput[$timeZone[1]] = $content;
     }
     echo Html::activeDropDownList($this->model, $this->attribute, $timeZonesOutput, $this->options);
 }
Example #8
0
 public function init()
 {
     parent::init();
     $this->_inputStr = '<div class="form-group">';
     $this->_inputStr .= Html::activeLabel($this->model, $this->attribute);
     $this->_inputStr .= Html::activeDropDownList($this->model, $this->attribute, \common\models\User::getUserGroup(), $this->options);
     $this->_inputStr .= '</div>';
 }
 /**
  * Renders the widget.
  */
 public function run()
 {
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->_getItems(), $this->options);
     } else {
         return Html::dropDownList($this->name, $this->value, $this->_getItems(), $this->options);
     }
 }
Example #10
0
 /**
  * Render dropdown list
  */
 public function renderDropDown()
 {
     if ($this->hasModel()) {
         echo Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     } else {
         echo Html::dropDownList($this->name, $this->value, $this->items, $this->options);
     }
 }
Example #11
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->registerClientScript();
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     } else {
         return Html::dropDownList($this->name, $this->value, $this->items, $this->options);
     }
 }
Example #12
0
 public function run()
 {
     $output[] = Html::activeDropDownList($this->model, $this->province['attribute'], $this->province['items'], $this->province['options']);
     $output[] = Html::activeDropDownList($this->model, $this->city['attribute'], $this->city['items'], $this->city['options']);
     if (!empty($this->district)) {
         $output[] = Html::activeDropDownList($this->model, $this->district['attribute'], $this->district['items'], $this->district['options']);
     }
     return @implode("\n", $output);
 }
 /**
  * Render chosen select
  * @return string|void
  */
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     } else {
         echo Html::dropDownList($this->name, $this->value, $this->items, $this->options);
     }
     $this->registerAssets();
 }
Example #14
0
 public function run()
 {
     $this->registerJqueryPlugin('material_select');
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     } else {
         return Html::dropDownList($this->name, $this->value, $this->items, $this->options);
     }
 }
 public static function defaultColumns()
 {
     return ['ip' => ['class' => MainColumn::class, 'filterAttribute' => 'ip_like'], 'tags' => ['format' => 'raw', 'attribute' => 'tag', 'header' => Yii::t('hipanel:hosting', 'Tags'), 'visible' => Yii::$app->user->can('admin'), 'filter' => function ($column, $model) {
         return Html::activeDropDownList($model, 'tag_in', array_merge(['' => Yii::t('hipanel', '---')], static::$ipTags), ['class' => 'form-control']);
     }, 'value' => function ($model) {
         $labels = [];
         foreach ($model->tags as $tag) {
             $labels[] = IpTag::widget(['tag' => $tag]);
         }
         return implode(' ', $labels);
     }], 'counters' => ['format' => 'html', 'header' => Yii::t('hipanel:hosting', 'Counters'), 'value' => function ($model) {
         $html = '';
         foreach ($model->objects_count as $count) {
             if ($count['type'] === 'hdomain') {
                 $url['ok'] = ['@hdomain', (new HdomainSearch())->formName() => ['ip_like' => $model->ip]];
                 $url['deleted'] = ['@hdomain', (new HdomainSearch())->formName() => ['ip_like' => $model->ip, 'state' => 'deleted']];
                 $type = function ($count) {
                     return Yii::t('hipanel:hosting', '{0, plural, one{domain} other{domains}}', (int) $count);
                 };
             } else {
                 throw new InvalidParamException('The object type is not supported', $model);
             }
             if ($count['ok']) {
                 $html .= Html::a((int) $count['ok'] . '&nbsp;' . FontIcon::i('fa-check') . ' ' . $type($count['ok']), $url['ok'], ['class' => 'btn btn-success btn-xs']);
             }
             $html .= ' ';
             if ($count['deleted'] > 0) {
                 $html .= Html::a((int) $count['deleted'] . '&nbsp;' . FontIcon::i('fa-trash') . ' ' . $type($count['deleted']), $url['deleted'], ['class' => 'btn btn-xs btn-warning']);
             }
         }
         return $html;
     }], 'links' => ['format' => 'html', 'value' => function ($model) {
         $items = [];
         foreach ($model->links as $link) {
             $item = Html::a($link->device, ['@server/view', 'id' => $link->device_id]);
             if ($link->service_id) {
                 $item .= '&nbsp;' . FontIcon::i('fa-long-arrow-right');
                 $item .= '&nbsp;' . Html::a($link->service ?: $link->soft, ['@service/view', 'id' => $link->service_id]);
             }
             $items[] = $item;
         }
         return ArraySpoiler::widget(['data' => $items, 'visibleCount' => 3]);
     }], 'services' => ['attribute' => 'links', 'format' => 'html', 'label' => Yii::t('hipanel:server', 'Services'), 'value' => function ($model) {
         return ArraySpoiler::widget(['data' => $model->links, 'formatter' => function ($link) {
             if (Yii::$app->user->can('support') && Yii::getAlias('@service', false)) {
                 return Html::a($link->service, ['@service/view', 'id' => $link->service_id]);
             }
             return $link->service;
         }]);
     }], 'actions' => ['class' => MenuColumn::class, 'menuClass' => IpActionsMenu::class], 'ptr' => ['options' => ['style' => 'width: 40%'], 'format' => 'raw', 'value' => function ($model) {
         if ($model->canSetPtr()) {
             return XEditable::widget(['model' => $model, 'attribute' => 'ptr', 'pluginOptions' => ['url' => Url::to('@ip/set-ptr')]]);
         }
         return null;
     }]];
 }
Example #16
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->items = ArrayHelper::merge(['' => ''], $this->items);
     $this->htmlOptions = ArrayHelper::merge($this->htmlOptions, ['class' => 'form-control']);
     if (!is_null($this->model)) {
         echo Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->htmlOptions);
     } else {
         echo Html::dropDownList($this->attribute, $this->value, $this->items, $this->htmlOptions);
     }
 }
Example #17
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         $html = Html::activeHiddenInput($this->model, $this->attribute, ["id" => null]);
         $html .= Html::activeDropDownList($this->model, $this->attribute, $this->data, $this->options);
     } else {
         $html = Html::hiddenInput($this->name, $this->value, ["id" => null]);
         $html .= Html::dropDownList($this->name, $this->value, $this->options);
     }
     return $html;
 }
 /**
  * run function.
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $randomId = uniqid();
     $tagsArray = ArrayHelper::map(FileTag::find()->select(['id', 'name'])->orderBy('name')->all(), 'id', 'name');
     $selectOptions = ArrayHelper::merge(['' => 'Select a File Tag'], $tagsArray);
     if ($this->hasModel()) {
         echo Html::activeDropDownList($this->model, $this->attribute, $selectOptions, $this->options);
     } else {
         echo Html::dropDownList($this->name, $this->value, $selectOptions, $this->options);
     }
 }
Example #19
0
 /**
  * Added possibility to add empty (not choosen) item to the items list.
  * @inheritdoc
  */
 public function dropDownList($items, $options = [])
 {
     $options = array_merge($this->inputOptions, $options);
     $this->adjustLabelFor($options);
     if (isset($options['emptyItem'])) {
         $items[null] = $options['emptyItem'];
         ksort($items);
     }
     $this->parts['{input}'] = Html::activeDropDownList($this->model, $this->attribute, $items, $options);
     return $this;
 }
Example #20
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     if (is_array($this->items)) {
         if (!isset($this->options['class']) or empty($this->options['class'])) {
             $this->options['class'] = 'form-control';
         }
         $items[''] = '';
         $items += $this->items;
         echo Html::activeDropDownList($this->model, $this->attribute, $items, $this->options);
     }
 }
 public function run()
 {
     if ($this->registerClientScripts) {
         $this->registerClientScripts();
     }
     $items = ArrayHelper::getColumn($this->context->textFormats, 'label', true);
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $items, $this->options);
     } else {
         return Html::dropDownList($this->name, $this->value, $items, $this->options);
     }
 }
Example #22
0
 /**
  * @inheritdoc
  */
 public function renderHtml()
 {
     if ($this->form !== null && $this->model !== null) {
         return $this->form->field($this->model, $this->attribute)->hint($this->hint)->dropDownList($this->items, $this->options);
     }
     if ($this->model !== null) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     }
     if (empty($this->options['multiple'])) {
         return Html::dropDownList($this->name, $this->value, $this->items, $this->options);
     } else {
         return Html::listBox($this->name, $this->value, $this->items, $this->options);
     }
 }
Example #23
0
 public function run()
 {
     $view = $this->getView();
     $id = $this->options['id'];
     //Register DtGridViewAsset
     SelectAsset::register($view);
     if ($this->model) {
         $content = Html::activeDropDownList($this->model, $this->attribute, $this->data, $this->options);
     } else {
         $content = Html::dropDownList($this->options['id'], $this->attribute, $this->data, $this->options);
     }
     $clientOptions = Json::encode($this->clientOptions);
     $view->registerJs("var uam_select" . $this->getId() . "=jQuery('#{$id}').select2({$clientOptions});");
     return $content;
 }
Example #24
-1
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if ($this->format == 'boolean') {
         $this->filter = [\Yii::t('app', 'No'), \Yii::t('app', 'Yes')];
     }
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . $error;
         } else {
             return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
Example #25
-1
 /**
  * Modifies the group input to let the user choose all existing groups.
  *
  * @param $cells
  * @return array
  */
 private function modifyGroupInput($cells)
 {
     foreach ($cells as $cell) {
         if (is_numeric(strpos($cell, '[group]'))) {
             $searchModel = new PasswordSearch();
             $acc_groups = Password::find()->select(['id', 'group'])->where(['is not', 'group', null])->asArray()->all();
             // Filter unique group items from all account credentials.
             $acc_groups = self::getUniqueArrItems($acc_groups, 'group');
             // Groups for which the user has access.
             $allowed_acc_groups = array();
             if (is_object(\Yii::$app->user->identity) && intval(\Yii::$app->user->identity->is_admin) !== 1) {
                 foreach ($acc_groups as $a_group) {
                     // Iterate all groups and check if user is allowed.
                     if (PasswordController::checkAccessByAccId($a_group['id'])) {
                         $allowed_acc_groups[] = $a_group;
                     }
                 }
             } else {
                 // Admin can access everything.
                 $allowed_acc_groups = $acc_groups;
             }
             $arr_dropdown = ArrayHelper::map($allowed_acc_groups, 'group', 'group');
             $cell = Html::activeDropDownList($searchModel, 'group', $arr_dropdown, ['class' => 'form-control', 'prompt' => 'Select Group']);
             $cell = $this->render('@app/modules/yiipass/views/elements/dropdown', array('group_input' => $cell));
         }
         // Remove "lastaccess" input. Working sorting is enough here. Input for date works not good.
         if (is_numeric(strpos($cell, '[lastaccess]'))) {
             $cell = '';
         }
         $new_cells[] = $cell;
     }
     return $new_cells;
 }
Example #26
-1
    protected function renderFilterCellContent()
    {
        //Getting Model Object From Class

        $model = Auction::createObject($this->modelClass);
        return Html::activeDropDownList($this->grid->filterModel,$this->filterAttribute,ArrayHelper::map($model->find()->distinct()->all() , 'id' , $this->modelAttribute),['class' => 'form-control','prompt' => '-------']);
    }
Example #27
-1
 /**
  * @inheritdoc
  */
 public function run()
 {
     switch ($this->response) {
         case static::RESPONSE_DEPDROP:
             $post = Yii::$app->request->post('depdrop_parents');
             break;
         case static::RESPONSE_HTML:
             $post = Yii::$app->request->post();
             break;
     }
     /** @var ActiveRecord $model */
     $model = $this->controller->findModel(false);
     $model->setAttributes(array_combine($this->postAttributes, array_values($post)));
     $method = GridHelper::listName($this->listAttribute);
     $list = $model->{$method}();
     switch ($this->response) {
         case static::RESPONSE_DEPDROP:
             Yii::$app->response->format = Response::FORMAT_JSON;
             $items = [];
             foreach ($list as $id => $name) {
                 $items[] = compact('id', 'name');
             }
             return ['output' => $items, 'selected' => ''];
             break;
         case static::RESPONSE_HTML:
             return Html::activeDropDownList($model, $this->listAttribute, $list);
             break;
         default:
             throw new Exception('Undefined list type');
     }
 }
Example #28
-1
 /**
  * @inheritdoc
  */
 public function run()
 {
     TagsInputAsset::register($this->getView());
     $this->registerClientScript();
     $output = Html::activeDropDownList($this->model, $this->attribute, $this->tags, ['class' => 'form-control', 'multiple' => $this->limit != 1]);
     return $output;
 }
 /**
  * Renders a dropdown list for the helper
  */
 protected function dropDownList()
 {
     if (!$this->selectBox) {
         return $this->hasModel() ? Html::activeDropDownList($this->model, $this->attribute, [], $this->options) : Html::dropDownList($this->name, $this->value, [], $this->options);
     } else {
         return Select::widget(['model' => $this->model, 'attribute' => $this->attribute, 'name' => $this->name, 'value' => $this->value, 'options' => $this->options]);
     }
 }
Example #30
-1
 /**
  * @inheritdoc
  * @return string
  */
 public function run()
 {
     $this->prepareItems();
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     }
     return Html::dropDownList($this->name, $this->value, $this->items, $this->options);
 }