Improve accessibility for price fields of the type select by adding the field label...
authorAlice Frumin <alice@aghstrategies.com>
Wed, 21 Jul 2021 15:03:12 +0000 (11:03 -0400)
committerAlice Frumin <alice@aghstrategies.com>
Mon, 26 Jul 2021 20:20:16 +0000 (16:20 -0400)
CRM/Price/BAO/PriceField.php

index f5435efda1ea4b50a0c89f96e3c234f68f69a015..8830e97cb0d5663866014acfa6b507201ce9d272 100644 (file)
@@ -525,13 +525,12 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField {
         else {
           $visibility_id = self::getVisibilityOptionID('public');
         }
-        $element = &$qf->add('select', $elementName, $label,
-          [
-            '' => ts('- select -'),
-          ] + $selectOption,
-          $useRequired && $field->is_required,
-          ['price' => json_encode($priceVal), 'class' => 'crm-select2', 'data-price-field-values' => json_encode($customOption)]
-        );
+        $element = &$qf->add('select', $elementName, $label, $selectOption, $useRequired && $field->is_required, [
+          'placeholder' => ts('- select %1 -', [1 => $label]),
+          'price' => json_encode($priceVal),
+          'class' => 'crm-select2',
+          'data-price-field-values' => json_encode($customOption),
+        ]);
 
         // CRM-6902 - Add "max" option for a price set field
         $button = substr($qf->controller->getButtonName(), -4);