Total Complexity | 6 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class ElementForm extends BaseElement |
||
12 | { |
||
13 | use UserForm; |
||
|
|||
14 | |||
15 | private static $table_name = 'ElementForm'; |
||
16 | |||
17 | private static $icon = 'font-icon-block-form'; |
||
18 | |||
19 | private static $controller_class = ElementFormController::class; |
||
20 | |||
21 | private static $singular_name = 'form'; |
||
22 | |||
23 | private static $plural_name = 'forms'; |
||
24 | |||
25 | private static $inline_editable = false; |
||
26 | |||
27 | /** |
||
28 | * @return UserForm |
||
29 | */ |
||
30 | public function Form() |
||
31 | { |
||
32 | $controller = UserDefinedFormController::create($this); |
||
33 | $current = Controller::curr(); |
||
34 | $controller->setRequest($current->getRequest()); |
||
35 | |||
36 | if ($current && $current->getAction() == 'finished') { |
||
37 | return $controller->renderWith(UserDefinedFormController::class .'_ReceivedFormSubmission'); |
||
38 | } |
||
39 | |||
40 | $form = $controller->Form(); |
||
41 | $form->setFormAction( |
||
42 | Controller::join_links( |
||
43 | $current->Link(), |
||
44 | 'element', |
||
45 | $this->owner->ID, |
||
46 | 'Form' |
||
47 | ) |
||
48 | ); |
||
49 | |||
50 | return $form; |
||
51 | } |
||
52 | |||
53 | public function Link($action = null) |
||
54 | { |
||
55 | $current = Controller::curr(); |
||
56 | |||
57 | if ($action === 'finished') { |
||
58 | return Controller::join_links( |
||
59 | $current->Link(), |
||
60 | 'finished' |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | return parent::Link($action); |
||
65 | } |
||
66 | |||
67 | public function getType() |
||
70 | } |
||
71 | } |
||
72 |