From: Coleman Watts Date: Fri, 27 Mar 2015 21:41:47 +0000 (-0400) Subject: CRM-16178 - That's more like it X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=030be0ceaa60ab24f99e415f98df5d631ffa5260;p=civicrm-core.git CRM-16178 - That's more like it --- diff --git a/CRM/Contact/Form/Edit/Individual.php b/CRM/Contact/Form/Edit/Individual.php index fb2841b047..373b7fe690 100644 --- a/CRM/Contact/Form/Edit/Individual.php +++ b/CRM/Contact/Form/Edit/Individual.php @@ -60,36 +60,26 @@ class CRM_Contact_Form_Edit_Individual { 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2' ); - - //prefix - $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - if (isset($nameFields['Prefix']) && !empty($prefix)) { - $form->addField('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix'))); - } - - if (isset($nameFields['Formal Title'])) { - $form->addField('formal_title'); - } - - // first_name - if (isset($nameFields['First Name'])) { - $form->addField('first_name'); + // Fixme: dear god why? these come out in a format that is NOT the name of the fields. + foreach ($nameFields as &$fix) { + $fix = str_replace(' ', '_', strtolower($fix)); + if ($fix == 'prefix' || $fix == 'suffix') { + // God, why god? + $fix .= '_id'; + } } - //middle_name - if (isset($nameFields['Middle Name'])) { - $form->addField('middle_name'); - } - - // last_name - if (isset($nameFields['Last Name'])) { - $form->addField('last_name'); - } - - // suffix - $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); - if (isset($nameFields['Suffix']) && $suffix) { - $form->addField('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix'))); + foreach ($nameFields as $name) { + $props = array(); + if ($name == 'prefix_id' || $name == 'suffix_id') { + $options = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name); + // Skip if we have no options available + if (!CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name)) { + //continue; + } + $props = array('class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix')); + } + $form->addField($name, $props); } } @@ -100,6 +90,7 @@ class CRM_Contact_Form_Edit_Individual { // job title // override the size for UI to look better $form->addField('job_title', array('size' => '30')); + //Current Employer Element $props = array( 'api' => array('params' => array('contact_type' => 'Organization')),