Merge pull request #4726 from atif-shaikh/CRM-5039
[civicrm-core.git] / CRM / Event / Form / ManageEvent / Conference.php
index 55b598a37f714e2c2874dbba2a956a93f7cb2f02..bc15ddfd17a2c0889a60f81104d253c9f3642b58 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | 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$
  *
  */
@@ -45,7 +45,7 @@ class CRM_Event_Form_ManageEvent_Conference extends CRM_Event_Form_ManageEvent {
   public $_action;
 
   /**
-   * This function sets the default values for the form. For edit/view mode
+   * Set default values for the form. For edit/view mode
    * the default values are retrieved from the database
    *
    * @access public
@@ -64,13 +64,6 @@ class CRM_Event_Form_ManageEvent_Conference extends CRM_Event_Form_ManageEvent {
 
     CRM_Event_BAO_Event::retrieve($params, $defaults);
 
-    if (isset($defaults['parent_event_id'])) {
-      $params = array('id' => $defaults['parent_event_id']);
-      $r_defaults = array();
-      $parent_event = CRM_Event_BAO_Event::retrieve($params, $r_defaults);
-      $defaults['parent_event_name'] = $parent_event->title;
-    }
-
     $defaults = array_merge($defaults, $parentDefaults);
     $defaults['id'] = $eventId;
 
@@ -78,7 +71,7 @@ class CRM_Event_Form_ManageEvent_Conference extends CRM_Event_Form_ManageEvent {
   }
 
   /**
-   * Function to build the form
+   * Build the form object
    *
    * @return void
    * @access public
@@ -94,8 +87,12 @@ class CRM_Event_Form_ManageEvent_Conference extends CRM_Event_Form_ManageEvent {
       FALSE
     );
 
-    $this->addElement('text', 'parent_event_name', ts('Parent Event'));
-    $this->addElement('hidden', 'parent_event_id');
+    $this->addEntityRef('parent_event_id', ts('Parent Event'),  array(
+        'entity' => 'event',
+        'placeholder' => ts('- any -'),
+        'select' => array('minimumInputLength' => 0),
+      )
+    );
 
     parent::buildQuickForm();
   }