1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class DMSDocumentCartSubmission extends DataObject |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
private static $db = array( |
|
|
|
|
6
|
|
|
'ReceiverName' => 'Varchar(100)', |
7
|
|
|
'ReceiverPhone' => 'Varchar(20)', |
8
|
|
|
'ReceiverEmail' => 'Varchar(254)', |
9
|
|
|
'DeliveryAddressLine1' => 'Varchar(200)', |
10
|
|
|
'DeliveryAddressLine2' => 'Varchar(200)', |
11
|
|
|
'DeliveryAddressCountry' => 'Varchar(50)', |
12
|
|
|
'DeliveryAddressPostCode' => 'Varchar(20)', |
13
|
|
|
); |
14
|
|
|
|
15
|
|
|
private static $has_many = array( |
|
|
|
|
16
|
|
|
'Items' => 'DMSDocumentCartSubmissionItem', |
17
|
|
|
); |
18
|
|
|
|
19
|
|
|
private static $summary_fields = array( |
|
|
|
|
20
|
|
|
'ReceiverName' => 'Receiver Name', |
21
|
|
|
'ReceiverPhone' => 'Receiver Phone', |
22
|
|
|
'ReceiverEmail' => 'Receiver Email', |
23
|
|
|
'Items.Count' => 'No. Items', |
24
|
|
|
'Created.Nice' => 'Created At' |
25
|
|
|
); |
26
|
|
|
|
27
|
|
|
private static $singular_name = 'Cart Submission'; |
|
|
|
|
28
|
|
|
private static $plural_name = 'Cart Submissions'; |
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Removing the add and existing GridField components to ensure that the model admin for submissions doesn't |
32
|
|
|
* let you add new records |
33
|
|
|
* |
34
|
|
|
* @return FieldList |
35
|
|
|
*/ |
36
|
|
|
public function getCMSFields() |
37
|
|
|
{ |
38
|
|
|
// PHP 5.3 support |
39
|
|
|
$self = $this; |
40
|
|
|
$this->beforeUpdateCMSFields(function (FieldList $fields) use ($self) { |
41
|
|
|
$fields->addFieldToTab('Root.Main', ReadonlyField::create('Created')); |
42
|
|
|
|
43
|
|
|
$gridField = GridField::create('Items', null, $self->Items(), $config = new GridFieldConfig_RecordEditor); |
|
|
|
|
44
|
|
|
$fields->addFieldToTab('Root.Items', $gridField); |
45
|
|
|
|
46
|
|
|
foreach (array('GridFieldAddExistingAutocompleter', 'GridFieldAddNewButton') as $component) { |
47
|
|
|
$config->removeComponentsByType($component); |
48
|
|
|
} |
49
|
|
|
}); |
50
|
|
|
return parent::getCMSFields(); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
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.