From: colemanw Date: Sun, 3 Dec 2023 18:03:05 +0000 (+0000) Subject: APIv4 - Pass form values to autocomplete field X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5071a76b1df28c65a9e938c6c72d3f6b413729fb;p=civicrm-core.git APIv4 - Pass form values to autocomplete field --- diff --git a/Civi/Api4/Generic/AutocompleteAction.php b/Civi/Api4/Generic/AutocompleteAction.php index 183043e3a8..cd80283b96 100644 --- a/Civi/Api4/Generic/AutocompleteAction.php +++ b/Civi/Api4/Generic/AutocompleteAction.php @@ -36,6 +36,7 @@ use Civi\Core\Event\GenericHookEvent; */ class AutocompleteAction extends AbstractAction { use Traits\SavedSearchInspectorTrait; + use Traits\GetSetValueTrait; /** * Autocomplete search input for search mode @@ -88,6 +89,17 @@ class AutocompleteAction extends AbstractAction { */ protected $key; + /** + * Known entity values. + * + * Value will be populated by the form based on data entered at the time. + * They can be used by hooks for contextual filtering. + * + * Format: [fieldName => value][] + * @var array + */ + protected $values = []; + /** * Search conditions that will be automatically added to the WHERE or HAVING clauses * diff --git a/ext/afform/core/ang/af/fields/EntityRef.html b/ext/afform/core/ang/af/fields/EntityRef.html index cd415943b9..28bd70cf82 100644 --- a/ext/afform/core/ang/af/fields/EntityRef.html +++ b/ext/afform/core/ang/af/fields/EntityRef.html @@ -5,7 +5,7 @@ ng-model="getSetSelect" ng-model-options="{getterSetter: true}" crm-autocomplete="$ctrl.defn.fk_entity" - crm-autocomplete-params="{formName: 'afform:' + $ctrl.afFieldset.getFormName(), fieldName: $ctrl.afFieldset.getName() + ':' + $ctrl.fieldName}" + crm-autocomplete-params="{formName: 'afform:' + $ctrl.afFieldset.getFormName(), fieldName: $ctrl.afFieldset.getName() + ':' + $ctrl.fieldName, values: dataProvider.getFieldData()}" multi="$ctrl.defn.input_attrs.multiple" auto-open="$ctrl.defn.input_attrs.autoOpen" quick-add="$ctrl.defn.input_attrs.quickAdd"