From f4d559bf010bdb9437dfd37f56c1c300e5dc1c25 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Mon, 15 Dec 2025 13:58:00 -0500 Subject: [PATCH] Restructure CoreEnroller for top-level form generation (CFM-218) (#355) --- .../templates/ApprovalCollectors/dispatch.inc | 2 +- .../BasicAttributeCollectors/dispatch.inc | 2 +- .../InvitationAccepters/dispatch.inc | 2 +- .../element/emailVerifiers/verify.php | 2 +- .../CoreEnroller/templates/element/field.php | 2 +- .../templates/element/fieldDiv.php | 75 ++++++++++++++++ .../templates/element/listItem.php | 88 +++++++++++++++++++ .../templates/element/unorderedList.php | 68 ++++++++++++++ app/templates/Standard/dispatch.php | 2 +- 9 files changed, 237 insertions(+), 6 deletions(-) create mode 100644 app/plugins/CoreEnroller/templates/element/fieldDiv.php create mode 100644 app/plugins/CoreEnroller/templates/element/listItem.php create mode 100644 app/plugins/CoreEnroller/templates/element/unorderedList.php 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/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