1 | <?php |
||
39 | class AttendeeExtraField extends DataObject |
||
40 | { |
||
41 | /** |
||
42 | * Field name to be used in the AttendeeField (Composite field) |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $fieldName; |
||
46 | |||
47 | private static $db = array( |
||
48 | 'Title' => 'Varchar(255)', |
||
49 | 'DefaultValue' => 'Varchar(255)', |
||
50 | 'ExtraClass' => 'Varchar(255)', |
||
51 | 'FieldName' => 'Varchar(255)', |
||
52 | 'Required' => 'Boolean', |
||
53 | 'Editable' => 'Boolean', |
||
54 | 'FieldType' => 'Enum("TextField,EmailField,CheckboxField,OptionsetField","TextField")', |
||
55 | 'Sort' => 'Int' |
||
56 | ); |
||
57 | |||
58 | private static $defaults = array( |
||
59 | 'Editable' => 1 |
||
60 | ); |
||
61 | |||
62 | private static $default_sort = 'Sort ASC'; |
||
63 | |||
64 | private static $has_one = array( |
||
65 | 'Event' => 'CalendarEvent' |
||
66 | ); |
||
67 | |||
68 | private static $has_many = array( |
||
69 | 'Options' => 'Broarm\EventTickets\AttendeeExtraFieldOption' |
||
70 | ); |
||
71 | |||
72 | private static $belongs_many_many = array( |
||
73 | 'Attendees' => 'Broarm\EventTickets\Attendee' |
||
74 | ); |
||
75 | |||
76 | private static $summary_fields = array( |
||
77 | 'Title' => 'Title', |
||
78 | 'FieldType' => 'FieldType', |
||
79 | 'Required.Nice' => 'Required' |
||
80 | ); |
||
81 | |||
82 | private static $translate = array( |
||
83 | 'Title' |
||
84 | ); |
||
85 | |||
86 | public function getCMSFields() |
||
125 | |||
126 | /** |
||
127 | * Returns the singular name without the namespaces |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | public function singular_name() |
||
136 | |||
137 | /** |
||
138 | * Set the Field name based on the title and ID |
||
139 | */ |
||
140 | public function onBeforeWrite() |
||
148 | |||
149 | /** |
||
150 | * Get the value casted based on chosen field type |
||
151 | * |
||
152 | * @return mixed|string |
||
153 | */ |
||
154 | public function getValue() |
||
165 | |||
166 | /** |
||
167 | * Create a field from given configuration |
||
168 | * |
||
169 | * @param $fieldName |
||
170 | * @param $fieldConfig |
||
171 | * |
||
172 | * @return AttendeeExtraField|DataObject |
||
173 | */ |
||
174 | public static function createFromConfig($fieldName, $fieldConfig) { |
||
191 | |||
192 | /** |
||
193 | * Create the configured field |
||
194 | * |
||
195 | * @param $fieldName |
||
196 | * @param $defaultValue |
||
197 | * |
||
198 | * @return \FormField |
||
199 | */ |
||
200 | public function createField($fieldName, $defaultValue = null) |
||
225 | |||
226 | public function canView($member = null) |
||
230 | |||
231 | public function canEdit($member = null) |
||
235 | |||
236 | public function canDelete($member = null) |
||
240 | |||
241 | public function canCreate($member = null) |
||
245 | } |
||
246 |