From: Coleman Watts Date: Mon, 25 Aug 2014 20:08:39 +0000 (+0100) Subject: CRM-15172 - Fix profile state/county required options X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e84e2993dfaa0a1122e3759957c1c35aebbadd61;p=civicrm-core.git CRM-15172 - Fix profile state/county required options --- diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index e26683a53b..fb3849b832 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1831,11 +1831,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) if (substr($fieldName, 0, 14) === 'state_province') { $controlField = str_replace('state_province', 'country', $name); if (isset($form->_fields[$controlField]) || in_array($controlField, $fieldsProcessed)) { - $form->addChainSelect($name, array('label' => $title, 'required' => $required)); + $form->addChainSelect($name, array('label' => $title, 'required' => $required)); } else { + $options = CRM_Core_PseudoConstant::stateProvince(); $form->add('select', $name, $title, - array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(), $required); + array('' => ts('- select -')) + $options, $required && $options); } $config = CRM_Core_Config::singleton(); if (!in_array($mode, array( @@ -1859,7 +1860,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } elseif (substr($fieldName, 0, 6) === 'county') { if ($addressOptions['county']) { - $form->addChainSelect($name, array('label' => $title, 'required' => $required)); + $controlField = str_replace('county', 'state_province', $name); + if (isset($form->_fields[$controlField]) || in_array($controlField, $fieldsProcessed)) { + $form->addChainSelect($name, array('label' => $title, 'required' => $required)); + } + else { + $options = CRM_Core_PseudoConstant::county(); + $form->add('select', $name, $title, + array('' => ts('- select -')) + $options, $required && $options); + } } } elseif (substr($fieldName, 0, 9) === 'image_URL') {