From 0e4f691608e5e866438754a30f2c650b6d761cc5 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Fri, 27 Sep 2024 17:12:42 +0300 Subject: [PATCH] Make dispatch view editable --- .../AttributeCollectors/dispatch.inc | 45 +++++++++++-------- .../templates/AttributeCollectors/fields.inc | 2 + 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/plugins/CoreEnroller/templates/AttributeCollectors/dispatch.inc b/app/plugins/CoreEnroller/templates/AttributeCollectors/dispatch.inc index 86257c536..f9c4ee9ff 100644 --- a/app/plugins/CoreEnroller/templates/AttributeCollectors/dispatch.inc +++ b/app/plugins/CoreEnroller/templates/AttributeCollectors/dispatch.inc @@ -1,6 +1,6 @@ firstMatch(['enrollment_attribute_id' => $attr->id]); +// Make the Form fields editable +$this->Field->enableFormEditMode(); - if(!empty($curEntity->value)) { - $options['default'] = $curEntity->value; - } - } +foreach($vv_enrollment_attributes as $attr) { + $options = []; + + if(!empty($vv_petition_attributes)) { + $curEntity = $vv_petition_attributes->firstMatch(['enrollment_attribute_id' => $attr->id]); - print $this->element('form/listItem', [ - 'arguments' => [ - // We prefix the attribute ID with a string because Cake seems to sometimes have - // problems with field names that are purely integers (even if cast to strings) - 'fieldName' => 'field-' . $attr->id, - 'fieldOptions' => $options, - 'fieldLabel' => $attr->label - ] - ]); + if(!empty($curEntity->value)) { + $options['default'] = $curEntity->value; + } } + + print $this->element('form/listItem', [ + 'arguments' => [ + // We prefix the attribute ID with a string because Cake seems to sometimes have + // problems with field names that are purely integers (even if cast to strings) + 'fieldName' => 'field-' . $attr->id, + 'fieldOptions' => $options, + 'fieldLabel' => $attr->label + ] + ]); } \ No newline at end of file diff --git a/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc b/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc index 2fe713d4d..113565bee 100644 --- a/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc +++ b/app/plugins/CoreEnroller/templates/AttributeCollectors/fields.inc @@ -25,6 +25,8 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +declare(strict_types = 1); + // Currently this Configuration View has no fields $this->Field->disableFormEditMode();