Commit 1c8738dd authored by eileen's avatar eileen

#691 Make default country optional on setting form

This includes removing the default of 'United States'.... ahem!
parent 402d07a5
......@@ -177,6 +177,12 @@ trait CRM_Admin_Form_SettingTrait {
$options = civicrm_api3('Setting', 'getoptions', [
'field' => $setting,
])['values'];
if ($props['html_type'] === 'Select' && isset($props['is_required']) && $props['is_required'] === FALSE && !isset($options[''])) {
// If the spec specifies the field is not required add a null option.
// Why not if empty($props['is_required']) - basically this has been added to the spec & might not be set to TRUE
// when it is true.
$options = ['' => ts('None')] + $options;
}
}
if ($props['type'] === 'Boolean') {
$options = [$props['title'] => $props['name']];
......
......@@ -156,11 +156,11 @@ return array(
'html_attributes' => array(
//'class' => 'crm-select2',
),
'default' => '1228',
'add' => '4.4',
'title' => 'Default Country',
'is_domain' => 1,
'is_contact' => 0,
'is_required' => FALSE,
'description' => 'This value is selected by default when adding a new contact address.',
'help_text' => NULL,
'pseudoconstant' => array(
......
......@@ -509,6 +509,7 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase {
* CRM-19888 default country should be used if ambigous.
*/
public function testImportAmbiguousStateCountry() {
$this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
$countries = CRM_Core_PseudoConstant::country(FALSE, FALSE);
$this->callAPISuccess('Setting', 'create', array('countryLimit' => array(array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries))));
$this->callAPISuccess('Setting', 'create', array('provinceLimit' => array(array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries))));
......
......@@ -198,7 +198,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
* Get Billing empty contact - this will return generic defaults
*/
public function testProfileGetBillingEmptyContact() {
$this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
$params = array(
'profile_id' => array('Billing'),
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment