|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
*@author nicolaas[at]sunnysideup.co.nz |
|
5
|
|
|
*@description contains a list of form field and their explantions |
|
6
|
|
|
* |
|
7
|
|
|
**/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
class FormFieldExplanation extends DataObject |
|
|
|
|
|
|
11
|
|
|
{ |
|
12
|
|
|
public static $db = array( |
|
13
|
|
|
"Name" => "Varchar(255)", |
|
14
|
|
|
"Title" => "Varchar(255)", |
|
15
|
|
|
"Explanation" => "Varchar(255)", |
|
16
|
|
|
"AlternativeFieldLabel" => "Varchar(100)", |
|
17
|
|
|
"CustomErrorMessage" => "Varchar(100)", |
|
18
|
|
|
"CustomErrorMessageAdditional" => "Varchar(200)" |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
public static $has_one = array( |
|
22
|
|
|
"Parent" => "SiteTree" |
|
23
|
|
|
); |
|
24
|
|
|
|
|
25
|
|
|
public static $indexes = array( |
|
26
|
|
|
"Name" => true |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
public static $searchable_fields = array( |
|
30
|
|
|
"Title" => "PartialMatch" |
|
31
|
|
|
); |
|
32
|
|
|
|
|
33
|
|
|
public static $field_labels = array( |
|
34
|
|
|
"Name" => "Field Name", |
|
35
|
|
|
"Title" => "Label", |
|
36
|
|
|
"Explanation" => "Explanation", |
|
37
|
|
|
"AlternativeFieldLabel" => "Alternative Field Label (if any - replaces standard field label)", |
|
38
|
|
|
"CustomErrorMessage" => "Custom Error Message, shown when field is not entered", |
|
39
|
|
|
"CustomErrorMessageAdditional" => "Additional (sub-heading) Custom Error Message, shown when field is not entered" |
|
40
|
|
|
|
|
41
|
|
|
); |
|
42
|
|
|
public static $summary_fields = array( |
|
43
|
|
|
"Title" => "Title" |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
View Code Duplication |
public function getCMSFields() |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$fields = parent::getCMSFields(); |
|
49
|
|
|
$fields->removeByName("ParentID"); |
|
50
|
|
|
$fields->removeByName("Name"); |
|
51
|
|
|
$fields->replaceField("Title", new LiteralField("Title", "<h3>Edit the details for ".$this->Title."</h3>")); |
|
|
|
|
|
|
52
|
|
|
return $fields; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
View Code Duplication |
public function getFrontEndFields() |
|
|
|
|
|
|
56
|
|
|
{ |
|
57
|
|
|
$fields = parent::getFrontEndFields(); |
|
58
|
|
|
$fields->removeByName("ParentID"); |
|
59
|
|
|
$fields->removeByName("Name"); |
|
60
|
|
|
$fields->replaceField("Title", new LiteralField("Title", "<h3>Edit the details for ".$this->Title."</h3>")); |
|
|
|
|
|
|
61
|
|
|
return $fields; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public static $singular_name = "Form Field Explanation"; |
|
65
|
|
|
|
|
66
|
|
|
public static $plural_name = "Form Field Explanations"; |
|
67
|
|
|
} |
|
68
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.