$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']];
'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(
* 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))));
* Get Billing empty contact - this will return generic defaults
*/
public function testProfileGetBillingEmptyContact() {
-
+ $this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
$params = array(
'profile_id' => array('Billing'),
);