Use select2 for report forms
authorColeman Watts <coleman@civicrm.org>
Fri, 22 Aug 2014 15:36:23 +0000 (16:36 +0100)
committerColeman Watts <coleman@civicrm.org>
Fri, 22 Aug 2014 15:36:23 +0000 (16:36 +0100)
CRM/Report/Form.php
templates/CRM/common/stateCountry.tpl

index 2e70b5ac93310771c70b58d07ecc48f8d6afbeb9..cb0f65c7aade4cfeb7339eec2f2101c8e42e0abc 100644 (file)
@@ -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;
 
index f03b6c717bf19b3e44d2cc46995fefc3f60d94c2..a1e0e2f18b187e8e96aa94dd55305a3985352027 100644 (file)
         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}"