Merge pull request #2687 from giant-rabbit/event_info_custom_validation
[civicrm-core.git] / CRM / Campaign / Form / Campaign.php
index bfd1dd512ccf23173918f17b7cec767b7f53d837..e0f7f0ad41a33ca54b21731dacbdbe9a0912c1de 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$
  *
  */
@@ -119,7 +119,7 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     }
 
     // when custom data is included in form.
-    if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
+    if (!empty($_POST['hidden_custom'])) {
       $this->set('type', 'Campaign');
       $this->set('subType', CRM_Utils_Array::value('campaign_type_id', $_POST));
       $this->set('entityId', $this->_campaignId);
@@ -136,7 +136,7 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   function setDefaultValues() {
     $defaults = $this->_values;
@@ -215,9 +215,6 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
       return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
 
-    //campaign types.
-    $campaignTypes = CRM_Campaign_PseudoConstant::campaignType();
-
     //lets assign custom data type and subtype.
     $this->assign('customDataType', 'Campaign');
     $this->assign('entityID', $this->_campaignId);
@@ -238,18 +235,10 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     $this->addDateTime('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDateTime'));
 
     // add campaign type
-    $this->add('select', 'campaign_type_id', ts('Campaign Type'),
-      array(
-        '' => ts('- select -')) + $campaignTypes, TRUE,
-      array('onChange' => "CRM.buildCustomData( 'Campaign', this.value );")
-    );
+    $this->addSelect('campaign_type_id', array('onChange' => "CRM.buildCustomData( 'Campaign', this.value );"), TRUE);
 
     // add campaign status
-    $campaignStatus = CRM_Campaign_PseudoConstant::campaignStatus();
-    $this->addElement('select', 'status_id', ts('Campaign Status'),
-      array(
-        '' => ts('- select -')) + $campaignStatus
-    );
+    $this->addSelect('status_id');
 
     // add External Identifire Element
     $this->add('text', 'external_identifier', ts('External Id'),
@@ -314,7 +303,7 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
    * This function is used to add the rules (mainly global rules) for form.
    * All local rules are added near the element
    *
-   * @return None
+   * @return void
    * @access public
    * @see valid_date
    */
@@ -329,7 +318,7 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   public function postProcess() {
     // store the submitted values in an array