Skip to content

Commit

Permalink
Make dispatch view editable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis authored and arlen committed Oct 14, 2024
1 parent 4640e3a commit 688535b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
45 changes: 26 additions & 19 deletions app/plugins/CoreEnroller/templates/AttributeCollectors/dispatch.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* COmanage Registry Attribute Collector Petition Fields
* COmanage Registry Dispatch Fields
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
Expand All @@ -25,27 +25,34 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

// This view is intended to work with dispatch
if($vv_action == 'dispatch') {
foreach($vv_enrollment_attributes as $attr) {
$options = [];
if($vv_action !== 'dispatch') {
return;
}

if(!empty($vv_petition_attributes)) {
$curEntity = $vv_petition_attributes->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
]
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 688535b

Please sign in to comment.