Add helper function for setting form css classes
authorColeman Watts <coleman@civicrm.org>
Wed, 20 Aug 2014 16:01:48 +0000 (17:01 +0100)
committerColeman Watts <coleman@civicrm.org>
Wed, 20 Aug 2014 19:21:04 +0000 (20:21 +0100)
CRM/Contact/Form/Search.php
CRM/Core/Form.php
CRM/Core/Form/Search.php

index 6ac6b9f38a43f235ec94dbd56d0584a95121251b..7a0083b2f1209c69cbcea8df672b2b5b475c3de5 100644 (file)
@@ -337,7 +337,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
    */
   function buildQuickForm() {
     parent::buildQuickForm();
-    $this->setAttribute('class', 'crm-search-form crm-ajax-selection-form');
+    $this->addClass('crm-ajax-selection-form');
     CRM_Core_Resources::singleton()
       // jsTree is needed for tags popup
       ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
index 13a097844bd0b6b961a3c4034a855caf4206667a..7307c84c3a74da0bdad136bf1b733165e43c8d0b 100644 (file)
@@ -194,6 +194,15 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
   static function generateID() {
   }
 
+  /**
+   * Add one or more css classes to the form
+   * @param $className
+   */
+  public function addClass($className) {
+    $classes = $this->getAttribute('class');
+    $this->setAttribute('class', ($classes ? "$classes " : '') . $className);
+  }
+
   /**
    * register all the standard rules that most forms potentially use
    *
index 4f298d8c293d7886611829b3791715023ca8a2df..2acc04af1dc431edfb18b0869ebacb9247da792b 100644 (file)
@@ -99,7 +99,7 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
       ),
     ));
 
-    $this->setAttribute('class', 'crm-search-form');
+    $this->addClass('crm-search-form');
   }
 
   /**