public function generateSelectOptions($options, $attr)
    {
        $return = '';

        foreach ($options as $key => $value) {
            if (is_array($value)) {
                $subArray = $this->generateSelectOptions($value, $attr);

                $return .= $this->Html->tag(
                    'optgroup',
                    array(
                        'label' => $key
                    ),
                    $subArray,
                    true
                );
            } else {
                $optionsAttr = array('value' => $key);

                if (isset($attr['selected']) && $attr['selected'] == $key) {
                    $optionsAttr[] = 'selected';
                }

                $return .= $this->Html->tag(
                    'option',
                    $optionsAttr,
                    $value,
                    true
                );
            }
        }

        return $return;
    }
public function generateSelectOptions($options, $attr)
    {
        $return = '';

        foreach ($options as $key => $value) {
            if (is_array($value)) {
                $subArray = $this->generateSelectOptions($value, $attr);

                $return .= $this->Html->tag(
                    'optgroup',
                    array(
                        'label' => $key
                    ),
                    $subArray,
                    true
                );
            } else {
                $optionsAttr = array('value' => $key);

                if (isset($attr['selected']) && $attr['selected'] == $key) {
                    $optionsAttr[] = 'selected';
                }

                $return .= $this->Html->tag(
                    'option',
                    $optionsAttr,
                    $value,
                    true
                );
            }
        }

        return $return;
    }
public function generateSelectOptions ( $ options , $ attr ) { $ return = '' ; foreach ( $ options as $ key => $ value ) { if ( is_array ( $ value ) ) { $ subArray = $ this -> generateSelectOptions ( $ value , $ attr ) ; $ return .= $ this -> Html -> tag ( 'optgroup' , array ( 'label' => $ key ) , $ subArray , true ) ; } else { $ optionsAttr = array ( 'value' => $ key ) ; if ( isset ( $ attr [ 'selected' ] ) && $ attr [ 'selected' ] == $ key ) { $ optionsAttr [ ] = 'selected' ; } $ return .= $ this -> Html -> tag ( 'option' , $ optionsAttr , $ value , true ) ; } } return $ return ; }
generate the options for a select box

@param   array   array of options
@param   array   array of attributes
@return  string
generate the options for a select box