From 54b18f2dfc4a9749e27c674c5ab27b6b267ffca7 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Tue, 10 Oct 2017 10:37:25 +1300 Subject: [PATCH] =?UTF-8?q?Modify=20ElementForm=20to=20contain=20its?= =?UTF-8?q?=E2=80=99=20own=20form=20builder.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/form.svg | 18 ++++++ src/Control/ElementFormController.php | 25 +++++++++ src/Model/ElementForm.php | 55 +++++++++++++++++++ src/Model/ElementUserDefinedForm.php | 38 ------------- .../Elemental/UserForms/Model/ElementForm.ss | 3 + 5 files changed, 101 insertions(+), 38 deletions(-) create mode 100644 images/form.svg create mode 100644 src/Control/ElementFormController.php create mode 100644 src/Model/ElementForm.php delete mode 100644 src/Model/ElementUserDefinedForm.php create mode 100644 templates/DNADesign/Elemental/UserForms/Model/ElementForm.ss diff --git a/images/form.svg b/images/form.svg new file mode 100644 index 0000000..6c23ea3 --- /dev/null +++ b/images/form.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + diff --git a/src/Control/ElementFormController.php b/src/Control/ElementFormController.php new file mode 100644 index 0000000..fab316d --- /dev/null +++ b/src/Control/ElementFormController.php @@ -0,0 +1,25 @@ +getRequest()->isPOST()) { + // handle the post request. + $user = UserDefinedFormController::create($element); + $form = $user->Form(); + + $user->process($current->getRequest()->postVars(), $form); + } + } +} diff --git a/src/Model/ElementForm.php b/src/Model/ElementForm.php new file mode 100644 index 0000000..ad90af0 --- /dev/null +++ b/src/Model/ElementForm.php @@ -0,0 +1,55 @@ +getAction() == 'finished') { + return $controller->renderWith('ReceivedFormSubmission'); + } + + $form = $controller->Form(); + $form->setFormAction(Controller::join_links( + $current->Link(), + 'element', + $this->owner->ID + )); + + return $form; + } + + +} diff --git a/src/Model/ElementUserDefinedForm.php b/src/Model/ElementUserDefinedForm.php deleted file mode 100644 index 2897473..0000000 --- a/src/Model/ElementUserDefinedForm.php +++ /dev/null @@ -1,38 +0,0 @@ - UserDefinedForm::class - ); - - private static $table_name = 'ElementForm'; - - private static $title = 'Form Element'; - - public function ElementForm() - { - if ($this->Form()->exists()) { - $controller = new UserDefinedForm_Controller($this->Form()); - - $current = Controller::curr(); - - if ($current && $current->getAction() == 'finished') { - return $controller->renderWith('ReceivedFormSubmission'); - } - - $form = $controller->Form(); - - return $form; - } - } -} diff --git a/templates/DNADesign/Elemental/UserForms/Model/ElementForm.ss b/templates/DNADesign/Elemental/UserForms/Model/ElementForm.ss new file mode 100644 index 0000000..4c17e96 --- /dev/null +++ b/templates/DNADesign/Elemental/UserForms/Model/ElementForm.ss @@ -0,0 +1,3 @@ +
+ $ElementForm +