diff --git a/code/Model/EditableCustomRule.php b/code/Model/EditableCustomRule.php index 8cca3c9..98fc87f 100644 --- a/code/Model/EditableCustomRule.php +++ b/code/Model/EditableCustomRule.php @@ -165,7 +165,9 @@ class EditableCustomRule extends DataObject /** * Substitutes configured rule logic with it's JS equivalents and returns them as array elements + * * @return array + * @throws LogicException If the provided condition option was not able to be handled */ public function buildExpression() { diff --git a/code/Model/EditableFormField/EditableCheckbox.php b/code/Model/EditableFormField/EditableCheckbox.php index a7479a8..a6c7afd 100755 --- a/code/Model/EditableFormField/EditableCheckbox.php +++ b/code/Model/EditableFormField/EditableCheckbox.php @@ -45,8 +45,8 @@ class EditableCheckbox extends EditableFormField public function getFormField() { $field = CheckboxField::create($this->Name, $this->EscapedTitle, $this->CheckedDefault) - ->setFieldHolderTemplate('UserFormsCheckboxField_holder') - ->setTemplate('UserFormsCheckboxField'); + ->setFieldHolderTemplate(__CLASS__ . '_holder') + ->setTemplate(__CLASS__); $this->doUpdateFormField($field); diff --git a/code/Model/EditableFormField/EditableCheckboxGroupField.php b/code/Model/EditableFormField/EditableCheckboxGroupField.php index 7b9bc0e..ffb5fcd 100755 --- a/code/Model/EditableFormField/EditableCheckboxGroupField.php +++ b/code/Model/EditableFormField/EditableCheckboxGroupField.php @@ -26,8 +26,8 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField public function getFormField() { $field = UserFormsCheckboxSetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()); - $field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder'); - $field->setTemplate('UserFormsCheckboxSetField'); + $field->setFieldHolderTemplate(EditableMultipleOptionField::class . '_holder'); + $field->setTemplate('UserFormsCheckboxSetField'); // @todo // Set the default checked items $defaultCheckedItems = $this->getDefaultOptions(); diff --git a/code/Model/EditableFormField/EditableCountryDropdownField.php b/code/Model/EditableFormField/EditableCountryDropdownField.php index 3871286..a0ba528 100644 --- a/code/Model/EditableFormField/EditableCountryDropdownField.php +++ b/code/Model/EditableFormField/EditableCountryDropdownField.php @@ -6,6 +6,7 @@ use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Forms\DropdownField; use SilverStripe\i18n\i18n; use SilverStripe\UserForms\Model\EditableCustomRule; +use SilverStripe\UserForms\Model\EditableDropdownField; use SilverStripe\UserForms\Model\EditableFormField; /** @@ -38,7 +39,7 @@ class EditableCountryDropdownField extends EditableFormField $field = DropdownField::create($this->Name, $this->EscapedTitle) ->setSource(i18n::getData()->getCountries()) ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsDropdownField'); + ->setTemplate(EditableDropdownField::class); $this->doUpdateFormField($field); diff --git a/code/Model/EditableFormField/EditableDateField.php b/code/Model/EditableFormField/EditableDateField.php index 8cd09b5..c30077a 100755 --- a/code/Model/EditableFormField/EditableDateField.php +++ b/code/Model/EditableFormField/EditableDateField.php @@ -60,7 +60,7 @@ class EditableDateField extends EditableFormField $field = FormField::create($this->Name, $this->EscapedTitle, $defaultValue) ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsField'); + ->setTemplate(EditableFormField::class); $this->doUpdateFormField($field); diff --git a/code/Model/EditableFormField/EditableDropdown.php b/code/Model/EditableFormField/EditableDropdown.php index dbe5547..b30e72f 100755 --- a/code/Model/EditableFormField/EditableDropdown.php +++ b/code/Model/EditableFormField/EditableDropdown.php @@ -60,8 +60,8 @@ class EditableDropdown extends EditableMultipleOptionField public function getFormField() { $field = DropdownField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()) - ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsDropdownField'); + ->setFieldHolderTemplate(EditableFormField::class . '_holder') + ->setTemplate(__CLASS__); if ($this->UseEmptyString) { $field->setEmptyString(($this->EmptyString) ? $this->EmptyString : ''); diff --git a/code/Model/EditableFormField/EditableEmailField.php b/code/Model/EditableFormField/EditableEmailField.php index f323fd6..0a43316 100644 --- a/code/Model/EditableFormField/EditableEmailField.php +++ b/code/Model/EditableFormField/EditableEmailField.php @@ -32,7 +32,7 @@ class EditableEmailField extends EditableFormField { $field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default) ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsField'); + ->setTemplate(EditableFormField::class); $this->doUpdateFormField($field); diff --git a/code/Model/EditableFormField/EditableFileField.php b/code/Model/EditableFormField/EditableFileField.php index fcecbd5..43d6850 100755 --- a/code/Model/EditableFormField/EditableFileField.php +++ b/code/Model/EditableFormField/EditableFileField.php @@ -99,10 +99,10 @@ class EditableFileField extends EditableFormField { $field = FileField::create($this->Name, $this->EscapedTitle) ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsFileField'); + ->setTemplate(__CLASS__); $field->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsFileField'); + ->setTemplate(__CLASS__); $field->getValidator()->setAllowedExtensions( array_diff( diff --git a/code/Model/EditableFormField/EditableLiteralField.php b/code/Model/EditableFormField/EditableLiteralField.php index 7005239..05c4c8d 100644 --- a/code/Model/EditableFormField/EditableLiteralField.php +++ b/code/Model/EditableFormField/EditableLiteralField.php @@ -145,7 +145,7 @@ class EditableLiteralField extends EditableFormField $field = CompositeField::create($content) ->setName($this->Name) // ->setID($this->Name) // @todo - ->setFieldHolderTemplate('UserFormsLiteralField_holder'); + ->setFieldHolderTemplate(__CLASS__ . '_holder'); $this->doUpdateFormField($field); diff --git a/code/Model/EditableFormField/EditableMultipleOptionField.php b/code/Model/EditableFormField/EditableMultipleOptionField.php index d05f697..b5cde83 100644 --- a/code/Model/EditableFormField/EditableMultipleOptionField.php +++ b/code/Model/EditableFormField/EditableMultipleOptionField.php @@ -113,9 +113,9 @@ class EditableMultipleOptionField extends EditableFormField * @param string $toStage * @param bool $createNewVersion */ - public function doPublish($fromStage, $toStage, $createNewVersion = false) + public function copyVersionToStage($fromStage, $toStage, $createNewVersion = false) { - parent::doPublish($fromStage, $toStage, $createNewVersion); + parent::copyVersionToStage($fromStage, $toStage, $createNewVersion); $this->publishOptions($fromStage, $toStage, $createNewVersion); } @@ -134,7 +134,7 @@ class EditableMultipleOptionField extends EditableFormField // Publish all options foreach ($this->Options() as $option) { $seenIDs[] = $option->ID; - $option->publish($fromStage, $toStage, $createNewVersion); + $option->copyVersionToStage($fromStage, $toStage, $createNewVersion); } // remove any orphans from the "fromStage" diff --git a/code/Model/EditableFormField/EditableNumericField.php b/code/Model/EditableFormField/EditableNumericField.php index 2818ac2..9952252 100755 --- a/code/Model/EditableFormField/EditableNumericField.php +++ b/code/Model/EditableFormField/EditableNumericField.php @@ -42,8 +42,8 @@ class EditableNumericField extends EditableFormField public function getFormField() { $field = NumericField::create($this->Name, $this->EscapedTitle, $this->Default) - ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsField') + ->setFieldHolderTemplate(EditableFormField::class . '_holder') + ->setTemplate(EditableFormField::class) ->addExtraClass('number'); $this->doUpdateFormField($field); diff --git a/code/Model/EditableFormField/EditableRadioField.php b/code/Model/EditableFormField/EditableRadioField.php index e366c73..3f2467a 100755 --- a/code/Model/EditableFormField/EditableRadioField.php +++ b/code/Model/EditableFormField/EditableRadioField.php @@ -36,8 +36,8 @@ class EditableRadioField extends EditableMultipleOptionField public function getFormField() { $field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()) - ->setFieldHolderTemplate('UserFormsMultipleOptionField_holder') - ->setTemplate('UserFormsOptionSetField'); + ->setFieldHolderTemplate(EditableMultipleOptionField::class . '_holder') + ->setTemplate('UserFormsOptionSetField'); // @todo // Set default item $defaultOption = $this->getDefaultOptions()->first(); diff --git a/code/Model/EditableFormField/EditableTextField.php b/code/Model/EditableFormField/EditableTextField.php index c388a53..9f142a7 100644 --- a/code/Model/EditableFormField/EditableTextField.php +++ b/code/Model/EditableFormField/EditableTextField.php @@ -129,13 +129,13 @@ class EditableTextField extends EditableFormField { if ($this->Rows > 1) { $field = TextareaField::create($this->Name, $this->EscapedTitle, $this->Default) - ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsTextareaField') + ->setFieldHolderTemplate(EditableFormField::class . '_holder') + ->setTemplate(str_replace('EditableTextField', 'EditableTextareaField', __CLASS__)) ->setRows($this->Rows); } else { $field = TextField::create($this->Name, $this->EscapedTitle, $this->Default) - ->setFieldHolderTemplate('UserFormsField_holder') - ->setTemplate('UserFormsField'); + ->setFieldHolderTemplate(EditableFormField::class . '_holder') + ->setTemplate(EditableFormField::class); } $this->doUpdateFormField($field); diff --git a/code/Model/Submission/SubmittedFormField.php b/code/Model/Submission/SubmittedFormField.php index d876169..469de56 100755 --- a/code/Model/Submission/SubmittedFormField.php +++ b/code/Model/Submission/SubmittedFormField.php @@ -31,7 +31,7 @@ class SubmittedFormField extends DataObject /** * @param Member $member - * + * @param array $context * @return boolean */ public function canCreate($member = null, $context = []) diff --git a/code/Model/UserDefinedFormController.php b/code/Model/UserDefinedFormController.php index 7a4ba54..bb637f6 100644 --- a/code/Model/UserDefinedFormController.php +++ b/code/Model/UserDefinedFormController.php @@ -433,7 +433,7 @@ JS $this->extend('updateReceivedFormSubmissionData', $data); return $this->customise([ - 'Content' => $this->customise($data)->renderWith('ReceivedFormSubmission'), + 'Content' => $this->customise($data)->renderWith(__CLASS__ . '_ReceivedFormSubmission'), 'Form' => '', ]); } diff --git a/templates/Includes/UserFormActionNav.ss b/templates/SilverStripe/UserForms/Form/Includes/UserFormActionNav.ss similarity index 100% rename from templates/Includes/UserFormActionNav.ss rename to templates/SilverStripe/UserForms/Form/Includes/UserFormActionNav.ss diff --git a/templates/Includes/UserFormProgress.ss b/templates/SilverStripe/UserForms/Form/Includes/UserFormProgress.ss similarity index 100% rename from templates/Includes/UserFormProgress.ss rename to templates/SilverStripe/UserForms/Form/Includes/UserFormProgress.ss diff --git a/templates/Includes/UserFormStepErrors.ss b/templates/SilverStripe/UserForms/Form/Includes/UserFormStepErrors.ss similarity index 100% rename from templates/Includes/UserFormStepErrors.ss rename to templates/SilverStripe/UserForms/Form/Includes/UserFormStepErrors.ss diff --git a/templates/Includes/UserFormStepNav.ss b/templates/SilverStripe/UserForms/Form/Includes/UserFormStepNav.ss similarity index 100% rename from templates/Includes/UserFormStepNav.ss rename to templates/SilverStripe/UserForms/Form/Includes/UserFormStepNav.ss diff --git a/templates/Includes/UserForm.ss b/templates/SilverStripe/UserForms/Form/UserForm.ss similarity index 67% rename from templates/Includes/UserForm.ss rename to templates/SilverStripe/UserForms/Form/UserForm.ss index 77fe039..16f8afd 100644 --- a/templates/Includes/UserForm.ss +++ b/templates/SilverStripe/UserForms/Form/UserForm.ss @@ -1,7 +1,7 @@
-<% include UserFormProgress %> -<% include UserFormStepErrors %> +<% include SilverStripe\\UserForms\\Form\\UserFormProgress %> +<% include SilverStripe\\UserForms\\Form\\UserFormStepErrors %> <% if $Message %>

$Message

@@ -21,9 +21,9 @@ <% end_if %> <% if $Steps.Count > 1 %> - <% include UserFormStepNav %> + <% include SilverStripe\\UserForms\\Form\\UserFormStepNav %> <% else %> - <% include UserFormActionNav %> + <% include SilverStripe\\UserForms\\Form\\UserFormActionNav %> <% end_if %>
diff --git a/templates/forms/UserFormsGroupField_holder.ss b/templates/SilverStripe/UserForms/FormField/UserFormsGroupField_holder.ss similarity index 99% rename from templates/forms/UserFormsGroupField_holder.ss rename to templates/SilverStripe/UserForms/FormField/UserFormsGroupField_holder.ss index 0ab7a23..8162e9c 100644 --- a/templates/forms/UserFormsGroupField_holder.ss +++ b/templates/SilverStripe/UserForms/FormField/UserFormsGroupField_holder.ss @@ -2,7 +2,7 @@ <% if $Tag == 'fieldset' && $Legend %> $Legend <% end_if %> - +
<% loop $FieldList %> <% if $ColumnCount %> diff --git a/templates/forms/UserFormsStepField.ss b/templates/SilverStripe/UserForms/FormField/UserFormsStepField.ss similarity index 100% rename from templates/forms/UserFormsStepField.ss rename to templates/SilverStripe/UserForms/FormField/UserFormsStepField.ss diff --git a/templates/forms/UserFormsField.ss b/templates/SilverStripe/UserForms/Model/EditableFormField.ss similarity index 100% rename from templates/forms/UserFormsField.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField.ss diff --git a/templates/forms/UserformsCheckboxField.ss b/templates/SilverStripe/UserForms/Model/EditableFormField/EditableCheckbox.ss similarity index 100% rename from templates/forms/UserformsCheckboxField.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField/EditableCheckbox.ss diff --git a/templates/forms/UserformsCheckboxField_holder.ss b/templates/SilverStripe/UserForms/Model/EditableFormField/EditableCheckbox_holder.ss similarity index 100% rename from templates/forms/UserformsCheckboxField_holder.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField/EditableCheckbox_holder.ss diff --git a/templates/forms/UserFormsDropdownField.ss b/templates/SilverStripe/UserForms/Model/EditableFormField/EditableDropdown.ss similarity index 100% rename from templates/forms/UserFormsDropdownField.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField/EditableDropdown.ss diff --git a/templates/forms/UserFormsFileField.ss b/templates/SilverStripe/UserForms/Model/EditableFormField/EditableFileField.ss similarity index 100% rename from templates/forms/UserFormsFileField.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField/EditableFileField.ss diff --git a/templates/forms/UserFormsLiteralField_holder.ss b/templates/SilverStripe/UserForms/Model/EditableFormField/EditableLiteralField_holder.ss similarity index 100% rename from templates/forms/UserFormsLiteralField_holder.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField/EditableLiteralField_holder.ss diff --git a/templates/forms/UserFormsMultipleOptionField_holder.ss b/templates/SilverStripe/UserForms/Model/EditableFormField/EditableMultipleOptionField_holder.ss similarity index 100% rename from templates/forms/UserFormsMultipleOptionField_holder.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField/EditableMultipleOptionField_holder.ss diff --git a/templates/forms/UserFormsTextareaField.ss b/templates/SilverStripe/UserForms/Model/EditableFormField/EditableTextareaField.ss similarity index 100% rename from templates/forms/UserFormsTextareaField.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField/EditableTextareaField.ss diff --git a/templates/forms/UserFormsField_holder.ss b/templates/SilverStripe/UserForms/Model/EditableFormField_holder.ss similarity index 100% rename from templates/forms/UserFormsField_holder.ss rename to templates/SilverStripe/UserForms/Model/EditableFormField_holder.ss diff --git a/templates/ReceivedFormSubmission.ss b/templates/SilverStripe/UserForms/Model/UserDefinedFormController_ReceivedFormSubmission.ss similarity index 100% rename from templates/ReceivedFormSubmission.ss rename to templates/SilverStripe/UserForms/Model/UserDefinedFormController_ReceivedFormSubmission.ss