From 93793e86a77de4dd56a27adc5e50a81580d66296 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 1 Mar 2014 20:37:14 -0500 Subject: [PATCH] CRM-13966 - Refactor event fee autocomplete --- CRM/Event/BAO/Query.php | 5 +--- CRM/Event/Page/AJAX.php | 8 +++--- templates/CRM/Event/Form/Search/Common.tpl | 31 +++++++++++++++++----- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 520773f152..2d504c76a7 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -565,10 +565,7 @@ class CRM_Event_BAO_Query { ), ) ); - $participantFee = &$form->add('text', 'participant_fee_level', ts('Fee Level')); - - //elements for assigning value operation - $participantFeeId = &$form->add('hidden', 'participant_fee_id', '', array('id' => 'participant_fee_id')); + $form->add('text', 'participant_fee_id', ts('Fee Level'), array('class' => 'big crm-ajax-select')); CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE); diff --git a/CRM/Event/Page/AJAX.php b/CRM/Event/Page/AJAX.php index 410c5e172f..89e6219797 100644 --- a/CRM/Event/Page/AJAX.php +++ b/CRM/Event/Page/AJAX.php @@ -40,9 +40,10 @@ class CRM_Event_Page_AJAX { /** * Function for building EventFee combo box + * FIXME: This ajax callback could be eliminated in favor of an entityRef field but the priceFieldValue api doesn't currently support filtering on entity_table */ function eventFee() { - $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String')); + $name = trim(CRM_Utils_Type::escape($_GET['term'], 'String')); if (!$name) { $name = '%'; @@ -61,9 +62,10 @@ GROUP BY cv.label"; $dao = CRM_Core_DAO::executeQuery($query); $results = array(); while ($dao->fetch()) { - $results[$dao->id] = $dao->label; + $results[] = array('id' => $dao->id, 'text' => $dao->label); } - CRM_Core_Page_AJAX::autocompleteResults($results); + echo json_encode($results); + CRM_Utils_System::civiExit(); } } diff --git a/templates/CRM/Event/Form/Search/Common.tpl b/templates/CRM/Event/Form/Search/Common.tpl index f209a72042..8f28ab2e99 100644 --- a/templates/CRM/Event/Form/Search/Common.tpl +++ b/templates/CRM/Event/Form/Search/Common.tpl @@ -65,8 +65,8 @@ - - {$form.participant_fee_level.label}
{$form.participant_fee_level.html} + + {$form.participant_fee_id.label}
{$form.participant_fee_id.html}
@@ -89,10 +89,27 @@ campaignTrClass='' campaignTdClass='crm-event-form-block-participant_campaign_id {literal} {/literal} -- 2.25.1