protected function OnPreRender()
 {
     # Build up child option controls for the select list
     $options = array();
     # Add blank option if requested
     if ($this->b_blank) {
         $options[] = new XhtmlOption();
     }
     # Loop through options, converting group names to option groups
     $current_group_name = '';
     $current_group = null;
     foreach ($this->GetControls() as $option) {
         /* @var $option XhtmlOption */
         # Same group as last option
         if ($option->GetGroupName() === $current_group_name) {
             if ($current_group_name) {
                 # Add option to the group
                 $current_group->AddControl($option);
             } else {
                 # It's not in a group
                 $options[] = $option;
             }
         } else {
             # Different group than last option
             if (!is_null($current_group)) {
                 $options[] = $current_group;
             }
             # If it's another group, create the group
             if ($option->GetGroupName()) {
                 $current_group_name = $option->GetGroupName();
                 $current_group = new XhtmlElement('optgroup', $option);
                 $current_group->AddAttribute('label', $current_group_name);
             } else {
                 # If we're now out of a group, clear the current groups
                 $current_group_name = '';
                 $current_group = null;
                 $options[] = $option;
             }
         }
     }
     # Add the final group, if there is one
     if (!is_null($current_group)) {
         $options[] = $current_group;
     }
     # Move child controls into select list
     $this->o_select->SetControls($options);
     $no_controls = array();
     $this->SetControls($no_controls);
     # Add select list to this control
     if ($this->GetLabel()) {
         if ($this->b_hide_label) {
             $o_label = new XhtmlElement('label');
             $o_label->SetCssClass('aural');
             $o_label->AddAttribute('for', $this->o_select->GetXhtmlId());
             $o_label->AddControl($this->GetLabel() . ' ');
             $this->AddControl($o_label);
             $this->AddControl($this->o_select);
         } else {
             $o_label = new XhtmlElement('label');
             $o_label->AddAttribute('for', $this->o_select->GetXhtmlId());
             $o_label->AddControl($this->GetLabel() . ' ');
             $o_label->AddControl($this->o_select);
             $this->AddControl($o_label);
         }
     } else {
         $this->AddControl($this->o_select);
     }
     parent::OnPreRender();
 }