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;
    }
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;
    }
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 ; }
Sets the element type to be a toggle

For toggle element $editlabel is not used.
$displayvalue must be specified, it can have text or icons but can not contain html links.

Toggle element can have two or more options.

@param array $options toggle options as simple, non-associative array; defaults to array(0,1)
@return self
Sets the element type to be a toggle