From 9b74cd6aa6d78503ee8da4ab73634c93e78004d7 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 6 Nov 2024 11:32:48 +0200 Subject: [PATCH] improvements --- .../Table/BasicAttributeCollectorsTable.php | 1 + .../CoreEnroller/templates/element/field.php | 19 ++++++++----------- .../element/mveas/fieldset-field.php | 1 - .../element/mveas/fieldset-group.php | 1 - app/src/View/Helper/FieldHelper.php | 4 ++++ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php index 5ed3d6aa0..1ec67cead 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php @@ -45,6 +45,7 @@ class BasicAttributeCollectorsTable extends Table { use \App\Lib\Traits\PrimaryLinkTrait; use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; + use \App\Lib\Traits\LayoutTrait; /** * Perform Cake Model initialization. diff --git a/app/plugins/CoreEnroller/templates/element/field.php b/app/plugins/CoreEnroller/templates/element/field.php index 0aa16367d..44ee1ce88 100644 --- a/app/plugins/CoreEnroller/templates/element/field.php +++ b/app/plugins/CoreEnroller/templates/element/field.php @@ -48,7 +48,7 @@ default => '' }; -// If we are re-rendering the Petition override the default value with whatever +// If we are re-rendering the Petition, override the default value with whatever // was previously saved if(!empty($vv_petition_attributes)) { $curEntity = $vv_petition_attributes->firstMatch(['enrollment_attribute_id' => $attr->id]); @@ -97,14 +97,11 @@ // Set the final fieldOptions $formArguments['fieldOptions'] = $options; -// HIDDEN Field -// We print directly, we do not delegate to the element for further processing -if ($attr->hidden) { +print match(true) { + // HIDDEN Field + // We print directly, we do not delegate to the element for further processing // In case this is a hidden field, we need to get only the value - print $this->Form->hidden($formArguments['fieldName'], ['value' => $options['default']]); -} else { - // Print the element - print $this->element('form/listItem', [ - 'arguments' => $formArguments - ]); -} \ No newline at end of file + $attr->hidden =>$this->Form->hidden($formArguments['fieldName'], ['value' => $options['default']]), + // Default use case + default => $this->element('form/listItem', ['arguments' => $formArguments]) +}; diff --git a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php index 754f861aa..95ef0999e 100644 --- a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php +++ b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php @@ -57,7 +57,6 @@
- element('form/requiredSpan') : ''?> element('form/requiredSpan') : ''?>
Field->formField(...$formArguments) ?> diff --git a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-group.php b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-group.php index 8ac21952a..380e77e8b 100644 --- a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-group.php +++ b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-group.php @@ -53,7 +53,6 @@ } $permitted_fields_list_flipped = array_flip($permitted_fields_list); - ?> $fields): ?> diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index 3f4b5cf13..8fcf3ad67 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -212,6 +212,10 @@ public function calculateLiClasses(): string $classes .= 'fields-people-autocomplete '; } + // Each field should have a class like `fields-` + $field = $vv_field_arguments['fieldNameAlias'] ?? $fieldName ?? 'unknown'; + $classes .= " fields-$field"; + return $classes; }