1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Team extends DataObject {

    static $db = array(
        "Name" => "Varchar",
        "Sort" => "Int",
        "Typ" => "Enum('Hockey, Tennis', 'Hockey')"
    );

    static $searchable_fields = array("Name");

    static $has_many = array(
        "Players" => "Player",
        "TeamNews" => "TeamNews",
    );

    static $many_many = array(
        "Editor" => "Member"
    );

    static $has_one = array(
        "Photo" => "Image"
    );

    function getCMSFields() {
        $fields = new FieldSet(
            new TabSet("Root",
                new Tab(_t("TeamManagementAdmin.TeamSettings", "Mannschaftseinstellungen"),
                    $idfield = new HiddenField("ID"),
                    new TextField("Name", _t("TeamManagementAdmin.TeamName", "Mannschaftsname")),
                    new ImageField("Photo", _t("TeamManagementAdmin.TeamPhoto", "Mannschaftsfoto"), null, null, null, "Teamphotos"),
                    new DropdownField("Typ", _t("TeamManagementAdmin.TeamTyp", "Abteilung"), singleton("Team")->dbObject("Typ")->enumValues())
                )
            )
        );
        $idfield->setValue($this->ID);
        return $fields;
    }

}