diff --git a/app/plugins/CoreEnroller/templates/ApprovalCollectors/dispatch.inc b/app/plugins/CoreEnroller/templates/ApprovalCollectors/dispatch.inc index 62375a0fb..2837b5bdc 100644 --- a/app/plugins/CoreEnroller/templates/ApprovalCollectors/dispatch.inc +++ b/app/plugins/CoreEnroller/templates/ApprovalCollectors/dispatch.inc @@ -63,7 +63,7 @@ $this->Field->enableFormEditMode(); ] ); - print $this->element('form/listItem', [ + print $this->element('CoreEnroller.listItem', [ 'arguments' => [ 'fieldName' => 'comment', 'fieldOptions' => [ diff --git a/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/dispatch.inc b/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/dispatch.inc index 8333415ae..e823825e6 100644 --- a/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/dispatch.inc +++ b/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/dispatch.inc @@ -59,7 +59,7 @@ $this->Field->enableFormEditMode(); element('form/listItem', [ + print $this->element('CoreEnroller.listItem', [ 'arguments' => [ 'fieldName' => 'mail', 'fieldOptions' => [ diff --git a/app/plugins/CoreEnroller/templates/InvitationAccepters/dispatch.inc b/app/plugins/CoreEnroller/templates/InvitationAccepters/dispatch.inc index c3f704581..0e9a2b328 100644 --- a/app/plugins/CoreEnroller/templates/InvitationAccepters/dispatch.inc +++ b/app/plugins/CoreEnroller/templates/InvitationAccepters/dispatch.inc @@ -36,7 +36,7 @@ if($vv_action == 'dispatch') { // Make the Form fields editable $this->Field->enableFormEditMode(); - print $this->element('form/listItem', [ + print $this->element('CoreEnroller.listItem', [ 'arguments' => [ 'fieldName' => 'accepted', 'fieldLabel' => __d('operation','accept.invitation'), diff --git a/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php b/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php index ce25aa05a..080bd9b6a 100644 --- a/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php +++ b/app/plugins/CoreEnroller/templates/element/emailVerifiers/verify.php @@ -72,7 +72,7 @@ print __d('core_enroller', 'information.EmailVerifiers.code_sent', [$vv_verify_address]); -print $this->element('form/listItem', [ +print $this->element('CoreEnroller.listItem', [ 'arguments' => [ 'fieldName' => 'code', 'fieldLabel' => __d('field', 'code'), diff --git a/app/plugins/CoreEnroller/templates/element/field.php b/app/plugins/CoreEnroller/templates/element/field.php index 80a3b8cd4..9166f9ca7 100644 --- a/app/plugins/CoreEnroller/templates/element/field.php +++ b/app/plugins/CoreEnroller/templates/element/field.php @@ -119,5 +119,5 @@ 'formArguments' => $formArguments ]), // Default use case - default => $this->Field->getElementsForDisabledInput('form/listItem', $formArguments) + default => $this->Field->getElementsForDisabledInput('CoreEnroller.listItem', $formArguments) }; diff --git a/app/plugins/CoreEnroller/templates/element/fieldDiv.php b/app/plugins/CoreEnroller/templates/element/fieldDiv.php new file mode 100644 index 000000000..0f1c84764 --- /dev/null +++ b/app/plugins/CoreEnroller/templates/element/fieldDiv.php @@ -0,0 +1,75 @@ + + +
+ element('form/nameDiv'); + + // This configuration isn't necessary anymore. + if(isset($vv_field_arguments['fieldDescription'])) { + unset($vv_field_arguments['fieldDescription']); + $this->set('vv_field_arguments', $vv_field_arguments); + } + + // Info Div + ?> +
+ element('form/infoDiv/withPrefix'); + } elseif(isset($vv_field_arguments['autocomplete'])) { + print $this->element('form/infoDiv/autocomplete'); + } elseif(isset($vv_field_arguments['status'])) { + print $this->element('form/infoDiv/status'); + } elseif(isset($vv_field_arguments['groupedControls'])) { + print $this->element('form/infoDiv/grouped'); + } elseif(isset($vv_field_arguments['entity'])) { + print $this->element('form/infoDiv/source'); + } elseif(isset($vv_field_arguments['groupmember'])) { + print $this->element('form/infoDiv/groupMember'); + } else { + print $this->element('form/infoDiv/default'); + } + + // Insert the afterField supplement: + if(!empty($vv_after_field)) { + print $vv_after_field; + } + ?> +
+
\ No newline at end of file diff --git a/app/plugins/CoreEnroller/templates/element/listItem.php b/app/plugins/CoreEnroller/templates/element/listItem.php new file mode 100644 index 000000000..7c02fd4f3 --- /dev/null +++ b/app/plugins/CoreEnroller/templates/element/listItem.php @@ -0,0 +1,88 @@ +set('fieldName', $arguments['fieldName']); + $fieldName = $arguments['fieldName']; + $this->set('vv_field_arguments', $arguments); + + // Pass along the field supplements if they are configured. + $this->set('vv_before_field', $beforeField ?? ''); + $this->set('vv_after_field', $afterField ?? ''); + + // If an attribute is frozen, inject a special link to unfreeze it, since + // the attribute is read-only and the admin can't simply uncheck the setting + if($fieldName == 'frozen' && $this->Field->getEntity()->frozen) { + $url = [ + 'label' => __d('operation', 'unfreeze'), + 'url' => [ + 'plugin' => null, + 'controller' => \App\Lib\Util\StringUtilities::entityToClassname($this->Field->getEntity()), + 'action' => 'unfreeze', + $this->Field->getEntity()->id + ] + ]; + $arguments = [ + ...$arguments, + 'status' => __d('field', 'frozen'), + 'link' => $url, + ]; + $this->set('vv_field_arguments', $arguments); + } + + // If an attribute is a plugin, return the link to its configuration + if($fieldName == 'plugin' && $vv_action == 'edit') { + $url = [ + 'label' => __d('operation', 'configure.plugin'), + 'url' => [ + 'plugin' => null, + 'controller' => \App\Lib\Util\StringUtilities::entityToClassname($this->Field->getEntity()), + 'action' => 'configure', + $this->Field->getEntity()->id + ] + ]; + $arguments = [ + ...$arguments, + 'status' => $this->Field->getEntity()->$fieldName, + 'link' => $url, + ]; + $this->set('vv_field_arguments', $arguments); + } + +?> + +
  • + element('CoreEnroller.fieldDiv')?> +
  • diff --git a/app/plugins/CoreEnroller/templates/element/unorderedList.php b/app/plugins/CoreEnroller/templates/element/unorderedList.php new file mode 100644 index 000000000..d0633c6f1 --- /dev/null +++ b/app/plugins/CoreEnroller/templates/element/unorderedList.php @@ -0,0 +1,68 @@ + + + + $v) { + print $this->Form->hidden($attr, ['value' => $v]); + } + } \ No newline at end of file diff --git a/app/templates/EnrollmentFlows/start.inc b/app/templates/EnrollmentFlows/start.inc index b4941bc5a..6026703ea 100644 --- a/app/templates/EnrollmentFlows/start.inc +++ b/app/templates/EnrollmentFlows/start.inc @@ -38,14 +38,11 @@ $modelTable = $this->Tab->getModelTableReference($modelsName); // For now, we just request the enrollee email. We're only called if // collect_enrollee_email is true, so we don't need to check it, though // if we ever add more fields to the start form we should. -print $this->element('form/listItem', [ - 'arguments' => [ - 'fieldName' => 'enrollee_email', - 'fieldOptions' => [ - 'required' => true - ], +$fields = [ + 'enrollee_email' => [ + 'required' => true, 'fieldType' => 'string' ] -]); +]; // Any hidden fields?? diff --git a/app/templates/EnrollmentFlows/start.php b/app/templates/EnrollmentFlows/start.php index 7dd28ede7..3c7066083 100644 --- a/app/templates/EnrollmentFlows/start.php +++ b/app/templates/EnrollmentFlows/start.php @@ -27,6 +27,10 @@ declare(strict_types = 1); +// Enrollment Flow Start has its own file of fields +$modelsName = $this->getName(); +$templatePath = $vv_template_path ?? ROOT . DS . "templates" . DS . $modelsName; +include($templatePath . DS . 'start.inc'); ?>
    @@ -38,8 +42,6 @@ element('flash') // Flash messages ?> set('vv_fields_inc', 'start.inc'); // Set form edit ability $this->set('vv_is_editable', true); @@ -49,7 +51,7 @@ 'type' => 'post', ]); // Form body -print $this->element('form/unorderedList'); +print $this->element('form/unorderedList', ['vv_fields' => $fields]); // Close the Form print $this->Form->end(); diff --git a/app/templates/Standard/dispatch.php b/app/templates/Standard/dispatch.php index 84d2e3352..c69be9295 100644 --- a/app/templates/Standard/dispatch.php +++ b/app/templates/Standard/dispatch.php @@ -81,7 +81,7 @@ // Form body print '
    '; -print $this->element('form/unorderedList'); +print $this->element('CoreEnroller.unorderedList'); print '
    '; // Inject the Petition ID into the form, though it will most likely