From 50a643269165308b255c3895826a14c2307af469 Mon Sep 17 00:00:00 2001 From: bach Date: Sun, 6 Sep 2026 10:37:06 +0200 Subject: [PATCH] =?UTF-8?q?Search=20field=5Fnumero=5Ffacture=20too=20in=20?= =?UTF-8?q?the=20entr=C3=A9e-li=C3=A9e=20autocomplete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several entrées for the same client often share the same title format ("EPAU - 2026-01-05"), so being able to type the invoice number itself is what actually finds the right one quickly. buildEntityQuery() withholds $match from the parent call (which would otherwise add its own title-only condition) and applies it manually as an OR across title and field_numero_facture instead. Verified live: searching "F2549" (not present in the title at all, only in field_numero_facture) now correctly surfaces that entrée; a title-only search and a no-match search both still behave as before. --- .../EntreeClientSelection.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php b/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php index f6bdd6e..32ab447 100644 --- a/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php +++ b/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php @@ -23,9 +23,16 @@ class EntreeClientSelection extends NodeSelection { /** * {@inheritdoc} + * + * Matches on title *or* field_numero_facture -- several entrées for the + * same client often share the same title format ("EPAU - 2026-01-05"), + * so being able to type the invoice number itself ("F2549") is what + * actually finds the right one quickly. $match is withheld from the + * parent call (it would otherwise add its own title-only condition) + * and applied manually below as an OR across both fields instead. */ protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { - $query = parent::buildEntityQuery($match, $match_operator); + $query = parent::buildEntityQuery(NULL, $match_operator); $query->condition('field_type_ligne', 'entree'); $entity = $this->configuration['entity'] ?? NULL; @@ -33,6 +40,14 @@ class EntreeClientSelection extends NodeSelection { $query->condition('field_client', $entity->get('field_client')->target_id); } + if (isset($match)) { + $query->condition( + $query->orConditionGroup() + ->condition('title', $match, $match_operator) + ->condition('field_numero_facture', $match, $match_operator) + ); + } + return $query; }