Swat/SwatGroupedFlydown.php
protected function displayNode(
        SwatTreeFlydownNode $node,
        $level = 0,
        $selected = false
    ) {
        $children = $node->getChildren();
        $flydown_option = $node->getOption();

        if (
            $level == 1 &&
            count($children) > 0 &&
            end($flydown_option->value) === null &&
            !($flydown_option instanceof SwatFlydownDivider)
        ) {
            $optgroup_tag = new SwatHtmlTag('optgroup');
            $optgroup_tag->label = $flydown_option->title;
            $optgroup_tag->open();
            foreach ($node->getChildren() as $child_node) {
                $this->displayNode($child_node, $level + 1, $selected);
            }

            $optgroup_tag->close();
        } else {
            $option_tag = new SwatHtmlTag('option');

            if ($this->serialize_values) {
                $salt = $this->getForm()->getSalt();
                $option_tag->value = SwatString::signedSerialize(
                    $flydown_option->value,
                    $salt
                );
            } else {
                $option_tag->value = (string) $flydown_option->values;
            }

            if ($flydown_option instanceof SwatFlydownDivider) {
                $option_tag->disabled = 'disabled';
                $option_tag->class = 'swat-flydown-option-divider';
            } else {
                $option_tag->removeAttribute('disabled');
                $option_tag->removeAttribute('class');
            }

            if (
                $this->path === $flydown_option->value &&
                $selected === false &&
                !($flydown_option instanceof SwatFlydownDivider)
            ) {
                $option_tag->selected = 'selected';
                $selected = true;
            } else {
                $option_tag->removeAttribute('selected');
            }

            $option_tag->setContent($flydown_option->title);
            $option_tag->display();

            foreach ($children as $child_node) {
                $this->displayNode($child_node, $level + 1, $selected);
            }
        }
    }
protected function displayNode(
        SwatTreeFlydownNode $node,
        $level = 0,
        $selected = false
    ) {
        $children = $node->getChildren();
        $flydown_option = $node->getOption();

        if (
            $level == 1 &&
            count($children) > 0 &&
            end($flydown_option->value) === null &&
            !($flydown_option instanceof SwatFlydownDivider)
        ) {
            $optgroup_tag = new SwatHtmlTag('optgroup');
            $optgroup_tag->label = $flydown_option->title;
            $optgroup_tag->open();
            foreach ($node->getChildren() as $child_node) {
                $this->displayNode($child_node, $level + 1, $selected);
            }

            $optgroup_tag->close();
        } else {
            $option_tag = new SwatHtmlTag('option');

            if ($this->serialize_values) {
                $salt = $this->getForm()->getSalt();
                $option_tag->value = SwatString::signedSerialize(
                    $flydown_option->value,
                    $salt
                );
            } else {
                $option_tag->value = (string) $flydown_option->values;
            }

            if ($flydown_option instanceof SwatFlydownDivider) {
                $option_tag->disabled = 'disabled';
                $option_tag->class = 'swat-flydown-option-divider';
            } else {
                $option_tag->removeAttribute('disabled');
                $option_tag->removeAttribute('class');
            }

            if (
                $this->path === $flydown_option->value &&
                $selected === false &&
                !($flydown_option instanceof SwatFlydownDivider)
            ) {
                $option_tag->selected = 'selected';
                $selected = true;
            } else {
                $option_tag->removeAttribute('selected');
            }

            $option_tag->setContent($flydown_option->title);
            $option_tag->display();

            foreach ($children as $child_node) {
                $this->displayNode($child_node, $level + 1, $selected);
            }
        }
    }
protected function displayNode ( SwatTreeFlydownNode $ node , $ level = 0 , $ selected = false ) { $ children = $ node -> getChildren ( ) ; $ flydown_option = $ node -> getOption ( ) ; if ( $ level == 1 && count ( $ children ) > 0 && end ( $ flydown_option -> value ) === null && ! ( $ flydown_option instanceof SwatFlydownDivider ) ) { $ optgroup_tag = new SwatHtmlTag ( 'optgroup' ) ; $ optgroup_tag -> label = $ flydown_option -> title ; $ optgroup_tag -> open ( ) ; foreach ( $ node -> getChildren ( ) as $ child_node ) { $ this -> displayNode ( $ child_node , $ level + 1 , $ selected ) ; } $ optgroup_tag -> close ( ) ; } else { $ option_tag = new SwatHtmlTag ( 'option' ) ; if ( $ this -> serialize_values ) { $ salt = $ this -> getForm ( ) -> getSalt ( ) ; $ option_tag -> value = SwatString :: signedSerialize ( $ flydown_option -> value , $ salt ) ; } else { $ option_tag -> value = ( string ) $ flydown_option -> values ; } if ( $ flydown_option instanceof SwatFlydownDivider ) { $ option_tag -> disabled = 'disabled' ; $ option_tag -> class = 'swat-flydown-option-divider' ; } else { $ option_tag -> removeAttribute ( 'disabled' ) ; $ option_tag -> removeAttribute ( 'class' ) ; } if ( $ this -> path === $ flydown_option -> value && $ selected === false && ! ( $ flydown_option instanceof SwatFlydownDivider ) ) { $ option_tag -> selected = 'selected' ; $ selected = true ; } else { $ option_tag -> removeAttribute ( 'selected' ) ; } $ option_tag -> setContent ( $ flydown_option -> title ) ; $ option_tag -> display ( ) ; foreach ( $ children as $ child_node ) { $ this -> displayNode ( $ child_node , $ level + 1 , $ selected ) ; } } }
Displays a grouped tree flydown node and its child nodes

Level 1 tree nodes are displayed as optgroups if their value is null,
they have children and they are not dividers.

@param SwatTreeFlydownNode $node the node to display.
@param integer $level the current level of the tree node.
@param array $path an array of values representing the tree path to
this node.
@param boolean $selected whether or not an element has been selected
yet.
Displays a grouped tree flydown node and its child nodes