Merge pull request #2876 from mepps/participant-image-event-badge
[civicrm-core.git] / CRM / Contact / Form / Edit / Individual.php
index 692d8e5d3193a2b5a5b90494ab0f65da588cddaa..8df832970ca9c33cab91e0d9ab13eb3a7824f4a6 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -44,7 +44,7 @@ class CRM_Contact_Form_Edit_Individual {
    * This function provides the HTML form elements that are specific
    * to the Individual Contact Type
    *
-   * @param object $form form object
+   * @param CRM_Core_Form $form form object
    * @param int $inlineEditMode ( 1 for contact summary
    * top bar form and 2 for display name edit )
    *
@@ -63,7 +63,7 @@ class CRM_Contact_Form_Edit_Individual {
       //prefix
       $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
       if (isset($nameFields['Prefix']) && !empty($prefix)) {
-        $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => '') + $prefix);
+        $form->addSelect('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix')));
       }
 
       $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
@@ -90,7 +90,7 @@ class CRM_Contact_Form_Edit_Individual {
       // suffix
       $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
       if (isset($nameFields['Suffix']) && $suffix) {
-        $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => '') + $suffix);
+        $form->addSelect('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix')));
       }
     }
 
@@ -106,11 +106,12 @@ class CRM_Contact_Form_Edit_Individual {
       $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
 
       //Current Employer Element
-      $employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $form->_contactId, FALSE, NULL, FALSE);
-      $form->assign('employerDataURL', $employerDataURL);
-
-      $form->addElement('text', 'current_employer', ts('Current Employer'), '');
-      $form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id'));
+      $props = array(
+        'api' => array('params' => array('contact_type' => 'Organization')),
+        'create' => TRUE,
+      );
+      $form->addEntityRef('employer_id', ts('Current Employer'), $props);
+      $attributes['source']['class'] = 'big';
       $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     }
 
@@ -144,9 +145,11 @@ class CRM_Contact_Form_Edit_Individual {
   /**
    * global form rule
    *
-   * @param array $fields  the input form values
-   * @param array $files   the uploaded files if any
-   * @param array $options additional user data
+   * @param array $fields the input form values
+   * @param array $files the uploaded files if any
+   * @param null $contactID
+   *
+   * @internal param array $options additional user data
    *
    * @return true if no errors, else array of errors
    * @access public
@@ -157,9 +160,7 @@ class CRM_Contact_Form_Edit_Individual {
     $primaryID = CRM_Contact_Form_Contact::formRule($fields, $errors, $contactID);
 
     // make sure that firstName and lastName or a primary OpenID is set
-    if (!$primaryID && (!CRM_Utils_Array::value('first_name', $fields) ||
-        !CRM_Utils_Array::value('last_name', $fields)
-      )) {
+    if (!$primaryID && (empty($fields['first_name']) || empty($fields['last_name']))) {
       $errors['_qf_default'] = ts('First Name and Last Name OR an email OR an OpenID in the Primary Location should be set.');
     }