From 30ab161a19df9de7837b9a05e494448d5b449001 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 22 Aug 2014 16:36:23 +0100 Subject: [PATCH] Use select2 for report forms --- CRM/Report/Form.php | 13 ++++++------- templates/CRM/common/stateCountry.tpl | 10 +++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 2e70b5ac93..cb0f65c7aa 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -921,13 +921,12 @@ class CRM_Report_Form extends CRM_Core_Form { if (count($operations) <= 1) { $element->freeze(); } - $select = $this->addElement('select', "{$fieldName}_value", NULL, - $field['options'], array( - 'size' => 4, - 'style' => 'min-width:250px', - ) - ); - $select->setMultiple(TRUE); + $this->addElement('select', "{$fieldName}_value", NULL, $field['options'], array( + 'style' => 'min-width:250px', + 'class' => 'crm-select2', + 'multiple' => TRUE, + 'placeholder' => ts('- select -'), + )); } break; diff --git a/templates/CRM/common/stateCountry.tpl b/templates/CRM/common/stateCountry.tpl index f03b6c717b..a1e0e2f18b 100644 --- a/templates/CRM/common/stateCountry.tpl +++ b/templates/CRM/common/stateCountry.tpl @@ -65,8 +65,12 @@ info.target.trigger('change'); } } - function initField(selector) { - return $(selector, $form).css('min-width', '20em').crmSelect2(); + function initField(selector, removePlaceholder) { + var $el = $(selector, $form); + if (removePlaceholder !== false) { + $el.removeAttr('placeholder'); + } + return $el.css('min-width', '20em').crmSelect2(); } {/literal} {foreach from=$config->stateCountryMap item=stateCountryMap} @@ -78,7 +82,7 @@ {rdelim}).on('change', chainSelect); {/if} {if $stateCountryMap.country && $stateCountryMap.state_province} - initField('select[name="{$stateCountryMap.country}"], select#{$stateCountryMap.country}').data('chainSelect', {ldelim} + initField('select[name="{$stateCountryMap.country}"], select#{$stateCountryMap.country}', false).data('chainSelect', {ldelim} callback: CRM.url('civicrm/ajax/jqState'), target: initField('select[name="{$stateCountryMap.state_province}"], #{$stateCountryMap.state_province}'), placeholder: "{ts escape='js'}Choose country first{/ts}" -- 2.25.1