From 29122482d2032fde02972b79c19948c093382d6e Mon Sep 17 00:00:00 2001 From: colemanw Date: Wed, 4 Oct 2023 08:32:03 -0400 Subject: [PATCH] Afform - Use list of allowed operators if set on the form, adjust width --- ext/afform/core/Civi/Afform/AfformMetadataInjector.php | 9 +++++++-- ext/afform/core/ang/af/afFieldWithSearchOperator.html | 2 +- ext/afform/core/ang/afCore.css | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/afform/core/Civi/Afform/AfformMetadataInjector.php b/ext/afform/core/Civi/Afform/AfformMetadataInjector.php index e92c638006..99ccaf77e2 100644 --- a/ext/afform/core/Civi/Afform/AfformMetadataInjector.php +++ b/ext/afform/core/Civi/Afform/AfformMetadataInjector.php @@ -126,8 +126,13 @@ class AfformMetadataInjector { // If 'operators' is present in the field definition, use it as a limiter // Afform expects 'operators' in the fieldDefn to be associative key/label, not just a flat array // like it is in the schema. - if (!empty($fieldInfo['operators'])) { - $operators = array_intersect_key($operators, array_flip($fieldInfo['operators'])); + $allowedOperators = $fieldInfo['operators'] ?? NULL; + // Use list of allowed operators if set on the form (should be in js plain array format) + if (!empty($fieldDefn['operators'])) { + $allowedOperators = \CRM_Utils_JS::decode($fieldDefn['operators']); + } + if ($allowedOperators) { + $operators = array_intersect_key($operators, array_flip($allowedOperators)); } $fieldDefn['operators'] = \CRM_Utils_JS::encode($operators); } diff --git a/ext/afform/core/ang/af/afFieldWithSearchOperator.html b/ext/afform/core/ang/af/afFieldWithSearchOperator.html index 3260716756..fbc037c3ef 100644 --- a/ext/afform/core/ang/af/afFieldWithSearchOperator.html +++ b/ext/afform/core/ang/af/afFieldWithSearchOperator.html @@ -1,4 +1,4 @@ -
diff --git a/ext/afform/core/ang/afCore.css b/ext/afform/core/ang/afCore.css index 86c4d09b6c..317cd1c473 100644 --- a/ext/afform/core/ang/afCore.css +++ b/ext/afform/core/ang/afCore.css @@ -36,6 +36,10 @@ af-form { display: inline-block; } +#bootstrap-theme .input-group .afform-search-operator { + width: 6rem; +} + [af-repeat-item] { position: relative; } -- 2.25.1