From ee015de4b2895ba738805cbb3c3b9e3cc6e86109 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 21 Nov 2014 12:06:58 +0530 Subject: [PATCH] optimised modification --- CRM/Core/BAO/UFGroup.php | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index bcf799c454..e0aff15c55 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1909,27 +1909,13 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) '' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required ); } - elseif ($fieldName === 'gender_id') { - $genderOptions = array(); - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); - foreach ($gender as $key => $var) { - $genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key); + elseif (in_array($fieldName, array('gender_id', 'communication_style_id'))) { + $options = array(); + $pseudoValues = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $fieldName); + foreach ($pseudoValues as $key => $var) { + $options[$key] = $form->createElement('radio', NULL, ts($title), $var, $key); } - $group = $form->addGroup($genderOptions, $name, $title); - if ($required) { - $form->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required'); - } - else { - $group->setAttribute('allowClear', TRUE); - } - } - elseif ($fieldName === 'communication_style_id') { - $styleOptions = array(); - $style = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'); - foreach ($style as $key => $var) { - $styleOptions[$key] = $form->createElement('radio', NULL, ts('Communication Style'), $var, $key); - } - $group = $form->addGroup($styleOptions, $name, $title); + $group = $form->addGroup($options, $name, $title); if ($required) { $form->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required'); } -- 2.25.1