Skip to content

Commit

Permalink
Standardize fields.inc 'type' and 'options'; add arbitrary HTML field…
Browse files Browse the repository at this point in the history
… (CFM-218)
  • Loading branch information
arlen committed Oct 7, 2025
1 parent 7c9f232 commit 620cdf5
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

$fields = [
'attribute' => [
'fieldType' => 'select'
'type' => 'select'
],
'ad_hoc_tag',
'affiliation_type_id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$fields = [
'server_id',
'table_mode' => [
'fieldType' => 'select'
'type' => 'select'
]
];

Expand Down
4 changes: 2 additions & 2 deletions app/plugins/CoreEnroller/templates/EmailVerifiers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ $fields = [
'required' => false,
'empty' => true,
'style' => $regexDisplayFirstTime || !empty($vv_obj?->verification_code_regex) ? '' : 'display: none;',
'fieldType' => 'select',
'fieldSelectOptions' => $permittedCharacters
'type' => 'select',
'options' => $permittedCharacters
],
'verification_code_charset' => [
'type' => 'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ if (
) {
$fields['attribute_mvea_parent'] = [
'empty' => false,
'fieldType' => 'select',
'fieldSelectOptions' => array_combine(
'type' => 'select',
'options' => array_combine(
$vv_supported_attributes[$attribute_type]['mveaParents'],
$vv_supported_attributes[$attribute_type]['mveaParents']
)
Expand All @@ -106,8 +106,8 @@ if (
$fields['attribute_type'] = [
'fieldLabel' => $attributes[$attribute_type] . ' Type',
'empty' => false,
'fieldType' => 'select',
'fieldSelectOptions' => $this->get($mveaAutoPopulatedVariable)
'type' => 'select',
'options' => $this->get($mveaAutoPopulatedVariable)
];
}
}
Expand All @@ -123,8 +123,8 @@ if(str_ends_with($attribute_type, '_id')) {
if ($this->get($defaultValuesPopulated) !== null) {
$fields['default_value'] = [
'empty' => true,
'fieldType' => 'select',
'fieldSelectOptions' => $this->get($defaultValuesPopulated)
'type' => 'select',
'options' => $this->get($defaultValuesPopulated)
];
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ if (
*/
if($attribute_type === 'valid_from') {
$fields['default_value_datetime'] = [
'fieldType' => 'datetime'
'type' => 'datetime'
];
}

Expand Down
4 changes: 2 additions & 2 deletions app/plugins/CoreServer/templates/Oauth2Servers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ $fields = [
],
'url',
'access_grant_type' => [
'fieldSelectOptions' => $types,
'fieldType' => 'select',
'options' => $types,
'type' => 'select',
'empty' => false
],
'clientid',
Expand Down
8 changes: 4 additions & 4 deletions app/plugins/OrcidSource/templates/OrcidSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ $fields = [
'required' => true
],
'api_type' => [
'fieldSelectOptions' => $api_types,
'fieldType' => 'select',
'options' => $api_types,
'type' => 'select',
'empty' => false,
'required' => true
],
'api_tier' => [
'fieldSelectOptions' => $api_tiers,
'fieldType' => 'select',
'options' => $api_tiers,
'type' => 'select',
'empty' => false,
'required' => true
],
Expand Down
2 changes: 1 addition & 1 deletion app/templates/CoSettings/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $fields = [
],
'person_picker_display_types' => [
'singleRowItem' => true,
'fieldLabel' => __d('field', 'CoSettings.person_picker_display_types')
'label' => __d('field', 'CoSettings.person_picker_display_types')
]
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
declare(strict_types=1);

// View vars
// $subtitle
// $content - the text or markup to be rendered
// $type - accepts "subtitle" or "html"
// $vv_action

if (empty($subtitle)) {
return;
if (empty($content)) {
return;
}

$unique = md5($subtitle);

?>

<!-- Close the previous one-->
</ul>
<!-- Add the header -->
<h3><?= $subtitle ?></h3>
<!-- Start a the new one -->
<ul id="<?= $vv_action . '_' . $this->name . '_' . $unique?>" class="fields form-list">
<li class="fields-subsection fields-subsection-<?= $type ?>">
<?php if($type === 'subtitle'): ?>
<h3><?= $content ?></h3>
<?php else: // we have arbitrary HTML ?>
<?= $content ?>
<?php endif; ?>
</li>
17 changes: 12 additions & 5 deletions app/templates/element/form/unorderedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@
// $vv_submit_button_label

?>
<ul id="<?= $vv_action . '_' . $this->name ?>" class="fields form-list">
<ul id="<?= $vv_action . '_' . $this->name ?>" class="<?= $vv_action . '_' . $this->name ?> fields form-list">
<?php
if(!empty($vv_fields)) {
// Output the visible fields from the fields.inc configuration
foreach($vv_fields as $key => $field) {
if($key === 'SUBTITLE') {
// We have a subtitle.
$subtitle = $field['subtitle'];
print $this->element('form/h3Inject', compact('subtitle'));
if($key === 'SUBTITLE' || $key === 'HTML') {
if($key === 'SUBTITLE') {
// We have a subtitle
$content = $field['subtitle'];
$type = 'subtitle';
} else {
// We have HTML to insert.
$content = $field['html'];
$type = 'html';
}
print $this->element('form/htmlInject', compact('content', 'type'));
} else {
// We have a normal field. Parse the configuration for strings or associative arrays.
if (is_int($key)) {
Expand Down
4 changes: 4 additions & 0 deletions app/webroot/css/co-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,10 @@ ul.form-list li fieldset:hover {
ul.form-list li .field.field-with-toggle:hover {
background-color: unset;
}
ul.form-list li.fields-subsection {
border-left: none;
border-right: none;
}
ul.form-list li.fields-submit {
background-color: unset;
border: none;
Expand Down

0 comments on commit 620cdf5

Please sign in to comment.