From 023e90c317eeb87e659854137063e1c0bee25b70 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 20 Aug 2014 17:01:48 +0100 Subject: [PATCH] Add helper function for setting form css classes --- CRM/Contact/Form/Search.php | 2 +- CRM/Core/Form.php | 9 +++++++++ CRM/Core/Form/Search.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 6ac6b9f38a..7a0083b2f1 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -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) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 13a097844b..7307c84c3a 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -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 * diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index 4f298d8c29..2acc04af1d 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -99,7 +99,7 @@ class CRM_Core_Form_Search extends CRM_Core_Form { ), )); - $this->setAttribute('class', 'crm-search-form'); + $this->addClass('crm-search-form'); } /** -- 2.25.1