Skip to content

ToggleButtonGroup doesn't work without model #126

@makroxyz

Description

@makroxyz

It works only passing model and attribute to the widget.

function run should be

public function run()
{
    if (!isset($this->options['item'])) {
        $this->options['item'] = [$this, 'renderItem'];
    }
    switch ($this->type) {
        case 'checkbox':
            if ($this->hasModel()) {
                return Html::activeCheckboxList($this->model, $this->attribute, $this->items, $this->options);
            } else {
                return Html::checkboxList($this->name, $this->value, $this->items, $this->options);
            }
        case 'radio':
            if ($this->hasModel()) {
                return Html::activeRadioList($this->model, $this->attribute, $this->items, $this->options); 
            } else {
                return Html::radioList($this->name, $this->value, $this->items, $this->options); 
            }
        default:
            throw new InvalidConfigException("Unsupported type '{$this->type}'");
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions