Пример #1
0
 /**
  * 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. The following options are specially handled:
  *
  * - prompt: string, a prompt text to be displayed as the first option;
  * - options: array, the attributes for the select option tags. The array keys must be valid option values,
  *   and the array values are the extra attributes for the corresponding option tags. For example,
  *
  * ~~~
  * [
  *     'value1' => ['disabled' => true],
  *     'value2' => ['label' => 'value 2'],
  * ];
  * ~~~
  *
  * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options',
  *   except that the array keys represent the optgroup labels specified in $items.
  *
  * The rest of the options will be rendered as the attributes of the resulting tag. The values will
  * be HTML-encoded using [[Html::encode()]]. If a value is null, the corresponding attribute will not be rendered.
  *
  * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly.
  *
  * @return static the field object itself
  */
 public function combobox($items, $options = [])
 {
     $options = array_merge($this->inputOptions, $options);
     $this->adjustLabelFor($options);
     $this->parts['{input}'] = Easyui::activeCombobox($this->model, $this->attribute, $items, $options);
     return $this;
 }