Beispiel #1
0
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     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();
     }
 }
 /**
  * Renders a drop-down list.
  * The selection of the drop-down list is taken from the value of the model attribute.
  * @param array $items the option data items. The array keys are option values, and the array values
  * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too).
  * For each sub-array, an option group will be generated whose label is the key associated with the sub-array.
  * If you have a list of data models, you may convert them into the format described above using
  * [[ArrayHelper::map()]].
  *
  * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in
  * the labels will also be HTML-encoded.
  * @param array $options the tag options in terms of name-value pairs.
  *
  * For the list of available options please refer to the `$options` parameter of [[\Leaps\Helper\Html::activeDropDownList()]].
  *
  * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly.
  *
  * @return $this the field object itself
  */
 public function dropDownList($items, $options = [])
 {
     $options = array_merge($this->inputOptions, $options);
     $this->adjustLabelFor($options);
     $this->parts['{input}'] = Html::activeDropDownList($this->model, $this->attribute, $items, $options);
     return $this;
 }