(dev/core#3865) Fix css for price fields of html type Select with long labels
authoryashodha <yashodha@cividesk.com>
Fri, 23 Sep 2022 07:29:43 +0000 (12:59 +0530)
committeryashodha <yashodha@cividesk.com>
Thu, 6 Oct 2022 06:18:12 +0000 (11:48 +0530)
CRM/Price/BAO/PriceField.php

index 06baa8a2ae8f052dc2a4ca081225af5b9a238ee7..05821e18f9788d9854a5d24f3aad81de7c9f8be8 100644 (file)
@@ -534,10 +534,20 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField {
         else {
           $visibility_id = self::getVisibilityOptionID('public');
         }
+
+        $class = '';
+        $maxlen = max(array_map('strlen', $selectOption));
+        if ($maxlen > 25) {
+          $class = ' huge';
+        }
+        if ($maxlen > 40) {
+          $class = ' huge40';
+        }
+
         $element = &$qf->add('select', $elementName, $label, $selectOption, $useRequired && $field->is_required, [
           'placeholder' => ts('- select %1 -', [1 => $label]),
           'price' => json_encode($priceVal),
-          'class' => 'crm-select2',
+          'class' => 'crm-select2' . $class,
           'data-price-field-values' => json_encode($customOption),
         ]);