1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\Admini\Subsites; |
4
|
|
|
|
5
|
|
|
use LeKoala\Tabulator\TabulatorGrid_ItemRequest; |
6
|
|
|
use SilverStripe\Forms\DropdownField; |
7
|
|
|
use SilverStripe\Forms\Form; |
8
|
|
|
use SilverStripe\Subsites\Model\Subsite; |
|
|
|
|
9
|
|
|
|
10
|
|
|
class TabulatorSubsiteDetailFormItemRequest extends TabulatorGrid_ItemRequest |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
private static $allowed_actions = [ |
14
|
|
|
'ItemEditForm', |
15
|
|
|
]; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Builds an item edit form. The arguments to getCMSFields() are the popupController and |
19
|
|
|
* popupFormName, however this is an experimental API and may change. |
20
|
|
|
* |
21
|
|
|
* @return Form |
22
|
|
|
* @see TabulatorGrid_ItemRequest::ItemEditForm() |
23
|
|
|
*/ |
24
|
|
|
public function ItemEditForm() |
25
|
|
|
{ |
26
|
|
|
$form = parent::ItemEditForm(); |
27
|
|
|
|
28
|
|
|
if ($this->record->ID == 0) { |
29
|
|
|
$templates = Subsite::get()->sort('Title'); |
30
|
|
|
$templateArray = []; |
31
|
|
|
if ($templates) { |
32
|
|
|
$templateArray = $templates->map('ID', 'Title'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$templateDropdown = new DropdownField( |
36
|
|
|
'TemplateID', |
37
|
|
|
_t('Subsite.COPYSTRUCTURE', 'Copy structure from:'), |
38
|
|
|
$templateArray |
39
|
|
|
); |
40
|
|
|
$templateDropdown->setEmptyString('(' . _t('Subsite.NOTEMPLATE', 'No template') . ')'); |
41
|
|
|
$form->Fields()->addFieldToTab('Root.Main', $templateDropdown); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return $form; |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function doSave($data, $form) |
48
|
|
|
{ |
49
|
|
|
$new_record = $this->record->ID == 0; |
50
|
|
|
if ($new_record && isset($data['TemplateID']) && !empty($data['TemplateID'])) { |
51
|
|
|
$template = Subsite::get()->byID(intval($data['TemplateID'])); |
52
|
|
|
if ($template) { |
53
|
|
|
$this->record = $template->duplicate(); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return parent::doSave($data, $form); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths