public function set_type_toggle($options = null) {
        if ($options === null) {
            $options = array(0, 1);
        }
        $options = array_values($options);
        $idx = array_search($this->value, $options, true);
        if ($idx === false) {
            throw new \coding_exception('Specified value must be one of the toggle options');
        }
        $nextvalue = ($idx < count($options) - 1) ? $idx + 1 : 0;

        $this->type = 'toggle';
        $this->options = (string)$nextvalue;
        return $this;
    }