CRM-14161 - Use select2 for sms & group selectors
authorColeman Watts <coleman@civicrm.org>
Tue, 15 Jul 2014 22:32:06 +0000 (23:32 +0100)
committerColeman Watts <coleman@civicrm.org>
Tue, 15 Jul 2014 22:32:06 +0000 (23:32 +0100)
CRM/SMS/Form/Group.php

index 61d9ea1a8048a48c056acd413684237c71f6c296..6270e4fe31e05b82a88214e623b746d06becdd00 100644 (file)
@@ -132,57 +132,40 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task {
     // run the groups through a hook so users can trim it if needed
     CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
 
-    $inG = &$this->addElement('advmultiselect', 'includeGroups',
-      ts('Include Group(s)') . ' ',
-      $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $select2style = array(
+      'multiple' => TRUE,
+      'style' => 'width: 100%; max-width: 60em;',
+      'class' => 'crm-select2',
+      'placeholder' => ts('- select -'),
     );
 
-    $this->addRule('includeGroups', ts('Please select a group to be SMSed.'), 'required');
-
-    $outG = &$this->addElement('advmultiselect', 'excludeGroups',
-      ts('Exclude Group(s)') . ' ',
+    $this->add('select', 'includeGroups',
+      ts('Include Group(s)'),
       $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+      TRUE,
+      $select2style
     );
 
-    $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
-    $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
+    $this->add('select', 'excludeGroups',
+      ts('Exclude Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
+    );
 
-    $inM = &$this->addElement('advmultiselect', 'includeMailings',
-      ts('INCLUDE Recipients of These Mailing(s)') . ' ',
+    $this->add('select', 'includeMailings',
+      ts('INCLUDE Recipients of These Message(s)'),
       $mailings,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+      FALSE,
+      $select2style
     );
-    $outM = &$this->addElement('advmultiselect', 'excludeMailings',
-      ts('EXCLUDE Recipients of These Mailing(s)') . ' ',
+    $this->add('select', 'excludeMailings',
+      ts('EXCLUDE Recipients of These Message(s)'),
       $mailings,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+      FALSE,
+      $select2style
     );
 
-    $inM->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $outM->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $inM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
-    $outM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
-
     $this->addFormRule(array('CRM_SMS_Form_Group', 'formRule'));
 
     $buttons = array(