core#2386 - metadata-driven chain-select fields
authorJon Goldberg <jon@megaphonetech.com>
Thu, 18 Feb 2021 18:29:58 +0000 (13:29 -0500)
committerJon Goldberg <jon@megaphonetech.com>
Thu, 18 Feb 2021 18:29:58 +0000 (13:29 -0500)
CRM/Admin/Form/SettingTrait.php
settings/Localization.setting.php

index 184caa73423c09b4bf5df2c10ef49b594a9462f3..61b45298b3f26394f151c9366d225e474ed7e812 100644 (file)
@@ -213,9 +213,7 @@ trait CRM_Admin_Form_SettingTrait {
           );
         }
         elseif ($add === 'addChainSelect') {
-          $this->addChainSelect($setting, [
-            'label' => $props['title'],
-          ]);
+          $this->addChainSelect($setting, ['label' => $props['title']] + $props['chain_select_settings']);
         }
         elseif ($add === 'addMonthDay') {
           $this->add('date', $setting, $props['title'], CRM_Core_SelectValues::date(NULL, 'M d'));
@@ -288,6 +286,7 @@ trait CRM_Admin_Form_SettingTrait {
       'text' => 'Element',
       'entity_reference' => 'EntityRef',
       'advmultiselect' => 'Element',
+      'chainselect' => 'ChainSelect',
     ];
     $mapping += array_fill_keys(CRM_Core_Form::$html5Types, '');
     return $mapping[$htmlType] ?? '';
index 6854b522594d8f5c702292a5143f639471491dc1..ec1be4f3bbfca877a7965c7094b1307b3a16cce8 100644 (file)
@@ -155,6 +155,9 @@ return [
     'type' => 'Integer',
     'quick_form_type' => 'ChainSelect',
     'html_type' => 'ChainSelect',
+    'chain_select_settings' => [
+      'control_field' => 'defaultContactCountry',
+    ],
     //'pseudoconstant' => array(
     //  'callback' => 'CRM_Core_PseudoConstant::stateProvince',
     //),