From b57d878ad409477e7001e1adc2d5927edd130495 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 24 Sep 2024 09:31:22 +0300 Subject: [PATCH] Fix EnrollmentAttributes fiels --- .../templates/EnrollmentAttributes/fields.inc | 283 +++++++++--------- 1 file changed, 136 insertions(+), 147 deletions(-) diff --git a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc index dd4d817d1..1948022cf 100644 --- a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc +++ b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc @@ -461,172 +461,161 @@ Field->control('label'); - - print $this->Field->control('description'); + foreach ( ['label', + 'description', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ]]); + } - print $this->Field->control( - fieldName: 'attribute', - options: [ - 'onChange' => 'updateGadgets()' + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'attribute', + 'fieldOptions' => [ + 'onChange' => 'updateGadgets()' + ] ] - ); + ]); - print $this->Field->control( - fieldName: 'attribute_mvea_parent', - controlType: 'select', - /* options: [ - // We default to an empty list then dynamically populate it - 'options' => ['Person', 'PersonRole'] - ]*/ - ); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'attribute_mvea_parent', + ] + ]); // This field is called attribute_type and not attribute_type_id because we want this // to behave as a hidden value populated by the appropriate select, and we don't want // Cake to implement foreign key automagic. - print $this->Field->control( - fieldName: 'attribute_type', - controlType: 'text' - ); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'attribute_type' + ]]); // These are the actual selects that will render for the appropriate Attribute - print $this->Field->control( - fieldName: 'address_type_id', - // Because these fields don't exist in the database, we need to explicitly set the controlType - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('address-type-id').value" - ] - ); - - print $this->Field->control( - fieldName: 'email_address_type_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('email-address-type-id').value" - ] - ); - - print $this->Field->control( - fieldName: 'identifier_type_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('identifier-type-id').value" - ] - ); - - print $this->Field->control( - fieldName: 'name_type_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('name-type-id').value" - ] - ); - - print $this->Field->control( - fieldName: 'pronoun_type_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('pronoun-type-id').value" - ] - ); - - print $this->Field->control( - fieldName: 'telephone_number_type_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('telephone-number-type-id').value" - ] - ); - - print $this->Field->control( - fieldName: 'url_type_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('url-type-id').value" - ] - ); - - print $this->Field->control('attribute_language'); - - print $this->Field->control('attribute_tag'); - - print $this->Field->control('status'); + foreach (['address_type_id', + 'email_address_type_id', + 'identifier_type_id', + 'name_type_id', + 'pronoun_type_id', + 'telephone_number_type_id', + 'url_type_id', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + 'fieldOptions' => [ + 'onChange' => "document.getElementById('attribute-type').value = document.getElementById('" . $field . "').value" + ] + ] + ]); + } - print $this->Field->control('ordr'); + foreach ( ['attribute_language', + 'attribute_tag', + 'status', + 'ordr', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ]]); + } - print $this->Field->control( - fieldName: 'default_value_validity_type', - controlType: 'select', - options: [ - 'options' => [ + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'default_value_validity_type', + 'fieldOptions' => [ 'on' => __d('core_enroller', 'enumeration.DefaultValueValidityType.on'), - 'after' => __d('core_enroller', 'enumeration.DefaultValueValidityType.after') - ], -// 'empty' => false, - 'onChange' => 'updateValidityGadgets()' - ] - ); + 'after' => __d('core_enroller', 'enumeration.DefaultValueValidityType.after'), + 'onChange' => 'updateValidityGadgets()' + ] + ]]); + +// print $this->Field->control( +// fieldName: 'default_value_validity_type', +// controlType: 'select', +// options: [ +// 'options' => [ +// 'on' => __d('core_enroller', 'enumeration.DefaultValueValidityType.on'), +// 'after' => __d('core_enroller', 'enumeration.DefaultValueValidityType.after') +// ], +//// 'empty' => false, +// 'onChange' => 'updateValidityGadgets()' +// ] +// ); // The default value is always stored in default_value, however for select based fields // (such as cou_id or affiliation) the value is copied into default_value and the // field specific attribute is used for display purposes only - print $this->Field->control('default_value'); - - print $this->Field->control( - fieldName: 'default_value_affiliation_type_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('default-value').value = document.getElementById('default-value-affiliation-type-id').value" - ] - ); - - print $this->Field->control( - fieldName: 'default_value_cou_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('default-value').value = document.getElementById('default-value-cou-id').value" - ] - ); - - print $this->Field->dateControl( - fieldName: 'default_value_datetime', - options: [ - ] - ); - - print $this->Field->control('default_value_env_name'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'default_value' + ]]); + + foreach (['default_value_affiliation_type_id', + 'default_value_cou_id', + 'default_value_group_id' + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + 'fieldOptions' => [ + 'onChange' => "document.getElementById('default-value').value = document.getElementById('" . $field . "').value" + ] + ] + ]); + } - print $this->Field->control( - fieldName: 'default_value_group_id', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('default-value').value = document.getElementById('default-value-group-id').value" - ] - ); + foreach ( ['default_value_datetime', + 'default_value_env_name', + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field + ]]); + } - print $this->Field->control('required', ['default' => true]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'required', + 'fieldOptions' => [ + 'default' => true + ] + ]]); // Like attribute_type, this is a "behind the scenes" field that is not directly edited - print $this->Field->control('attribute_required_fields'); - - print $this->Field->control( - fieldName: 'address_required_fields', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-required-fields').value = document.getElementById('address-required-fields').value" - ] - ); - - print $this->Field->control( - fieldName: 'name_required_fields', - controlType: 'select', - options: [ - 'onChange' => "document.getElementById('attribute-required-fields').value = document.getElementById('name-required-fields').value" - ] - ); - - print $this->Field->control('modifiable', ['default' => true]); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'attribute_required_fields' + ]]); + + foreach ([ + 'address_required_fields', + 'name_required_fields', + + ] as $field) { + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => $field, + 'fieldOptions' => [ + 'onChange' => "document.getElementById('attribute-required-fields').value = document.getElementById('" . $field . "').value" + ] + ] + ]); + } - print $this->Field->control('hidden'); + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'modifiable', + 'fieldOptions' => [ + 'default' => true + ] + ]]); + + print $this->element('form/listItem', [ + 'arguments' => [ + 'fieldName' => 'hidden' + ]]); }