/**
  * @access private
  * @return void
  * @desc Build control from supplied properties, ready for display
  */
 function OnPreRender()
 {
     # build element differently depending on mode
     switch ($this->i_mode) {
         case TextBoxMode::MultiLine():
             $this->SetElementName('textarea');
             $this->AddControl(Html::Encode($this->s_value));
             $this->RemoveAttribute('maxlength');
             // not valid option
             $this->AddAttribute('rows', 7);
             // arbitrary value to validate, will use CSS in practice
             $this->AddAttribute('cols', 40);
             // arbitrary value to validate, will use CSS in practice
             $this->SetEmpty(false);
             break;
         case TextBoxMode::Hidden():
             $this->AddAttribute('type', 'hidden');
             $this->AddAttribute('value', $this->s_value);
             $this->SetEmpty(true);
             break;
         case TextBoxMode::File():
             $this->AddAttribute('type', 'file');
             $this->SetEmpty(true);
             break;
         case TextBoxMode::Number():
             $this->AddAttribute('type', 'number');
             $this->AddAttribute('value', $this->s_value);
             $this->SetEmpty(true);
             break;
         default:
             if (!$this->GetAttribute("type")) {
                 $this->AddAttribute('type', 'text');
             }
             $this->AddAttribute('value', $this->s_value);
             $this->SetEmpty(true);
             break;
     }
 }
    /**
     * Creates the controls when the editor is in its team view
     *
     */
    private function CreateTeamControls(Match $match, XhtmlElement $match_box)
    {
        $css_class = 'TournamentEdit';
        $match_box->SetCssClass($css_class);
        $this->SetCssClass('');
        $match_box->SetXhtmlId($this->GetNamingPrefix());
        $this->AddControl($match_box);
        # Preserve match title and date, because we need them for the page title when "add" is clicked
        $title = new TextBox($this->GetNamingPrefix() . 'Title', $match->GetTitle(), $this->IsValidSubmit());
        $title->SetMode(TextBoxMode::Hidden());
        $match_box->AddControl($title);
        $date = new TextBox($this->GetNamingPrefix() . 'Start', $match->GetStartTime(), $this->IsValidSubmit());
        $date->SetMode(TextBoxMode::Hidden());
        $match_box->AddControl($date);
        $match_box->AddControl(<<<HTML
        
        <div class="panel"><div><div>
            <h2 class="large"><span><span><span>How many teams do you have room for?</span></span></span></h2>
            <p>Tell us how many teams you have room for and who's coming, and we'll list your tournament with how many spaces are left.</p>
HTML
);
        $max = new TextBox($this->GetNamingPrefix() . 'MaxTeams', $match->GetMaximumTeamsInTournament(), $this->IsValidSubmit());
        $max->SetMode(TextBoxMode::Number());
        $max->SetCssClass('max-teams numeric');
        $match_box->AddControl(new FormPart("Maximum teams", new XhtmlElement('div', $max)));
        $match_box->AddControl("</div></div></div>");
        # Teams editor
        $this->EnsureAggregatedEditors();
        $this->teams_editor->DataObjects()->SetItems($match->GetAwayTeams());
        $match_box->AddControl($this->teams_editor);
        # Change Save button to "Next" button
        if ($this->show_step_number) {
            $this->SetButtonText('Next &raquo;');
        }
    }