1 | <?php |
||
34 | class UserField extends DataObject |
||
35 | { |
||
36 | /** |
||
37 | * @var FormField |
||
38 | */ |
||
39 | protected $fieldType = 'FormField'; |
||
40 | |||
41 | /** |
||
42 | * Field name to be used in the AttendeeField (Composite field) |
||
43 | * |
||
44 | * @see AttendeeField::__construct() |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $fieldName; |
||
49 | |||
50 | private static $db = array( |
||
51 | 'Name' => 'Varchar(255)', // mostly here for default fields lookup |
||
52 | 'Title' => 'Varchar(255)', |
||
53 | 'Default' => 'Varchar(255)', |
||
54 | 'ExtraClass' => 'Varchar(255)', |
||
55 | 'Required' => 'Boolean', |
||
56 | 'Editable' => 'Boolean', |
||
57 | 'Sort' => 'Int' |
||
58 | ); |
||
59 | |||
60 | private static $defaults = array( |
||
61 | 'Editable' => 1 |
||
62 | ); |
||
63 | |||
64 | private static $default_sort = 'Sort ASC'; |
||
65 | |||
66 | private static $has_one = array( |
||
67 | 'Event' => 'CalendarEvent' |
||
68 | ); |
||
69 | |||
70 | private static $belongs_many_many = array( |
||
71 | 'Attendees' => 'Broarm\EventTickets\Attendee' |
||
72 | ); |
||
73 | |||
74 | private static $summary_fields = array( |
||
75 | 'singular_name' => 'Type of field', |
||
76 | 'Title' => 'Title', |
||
77 | 'RequiredNice' => 'Required field' |
||
78 | ); |
||
79 | |||
80 | private static $translate = array( |
||
81 | 'Title', |
||
82 | 'Default' |
||
83 | ); |
||
84 | |||
85 | public function getCMSFields() |
||
106 | |||
107 | public function onBeforeWrite() |
||
119 | |||
120 | /** |
||
121 | * Get the filed type |
||
122 | * |
||
123 | * @return FormField |
||
124 | */ |
||
125 | public function getFieldType() |
||
129 | |||
130 | /** |
||
131 | * Show if the field is required in a nice format |
||
132 | * |
||
133 | * BUGFIX Using the shorthand Required.Nice in the summary_fields |
||
134 | * made the fields, that were required (true), be set to (false) |
||
135 | * |
||
136 | * @return mixed |
||
137 | */ |
||
138 | public function getRequiredNice() |
||
142 | |||
143 | /** |
||
144 | * Get the value |
||
145 | * |
||
146 | * @return mixed|string |
||
147 | */ |
||
148 | public function getValue() |
||
152 | |||
153 | /** |
||
154 | * Create a field from given configuration |
||
155 | * These fields are created based on the set default fields @see Attendee::$default_fields |
||
156 | * |
||
157 | * @param $fieldName |
||
158 | * @param $fieldConfig |
||
159 | * |
||
160 | * @return UserField|DataObject |
||
161 | */ |
||
162 | public static function createDefaultField($fieldName, $fieldConfig) |
||
177 | |||
178 | /** |
||
179 | * Create the actual field |
||
180 | * Overwrite this on the field subclass |
||
181 | * |
||
182 | * @param $fieldName string Created by the AttendeeField |
||
183 | * @param $defaultValue string Set a default value |
||
184 | * |
||
185 | * @return FormField |
||
186 | */ |
||
187 | public function createField($fieldName, $defaultValue = null) |
||
195 | |||
196 | /** |
||
197 | * Returns the singular name without the namespaces |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | public function singular_name() |
||
206 | |||
207 | public function canView($member = null) |
||
211 | |||
212 | public function canEdit($member = null) |
||
216 | |||
217 | public function canDelete($member = null) |
||
221 | |||
222 | public function canCreate($member = null) |
||
226 | } |
||
227 |