CRM-13992 coding neccessary property values / configurable options required for tab...
[civicrm-core.git] / CRM / Custom / Form / Group.php
index 162c0a272e7339c3b4e9455202ac185fa56548a5..c18e36da4de27ceac0254f40573a58a96c5b4115 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -135,7 +135,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form {
       $errors['title'] = ts('Custom group \'%1\' already exists in Database.', array(1 => $title));
     }
 
-    if (CRM_Utils_Array::value(1, $fields['extends'])) {
+    if (!empty($fields['extends'][1])) {
       if (in_array('', $fields['extends'][1]) && count($fields['extends'][1]) > 1) {
         $errors['extends'] = ts("Cannot combine other option with 'Any'.");
       }
@@ -151,7 +151,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form {
       $self->assign('showStyle', TRUE);
     }
 
-    if (CRM_Utils_Array::value('is_multiple', $fields)) {
+    if (!empty($fields['is_multiple'])) {
         $self->assign('showMultiple', TRUE);
     }
 
@@ -243,7 +243,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form {
     $sel2['ParticipantRole'] = $participantRole;
     $sel2['ParticipantEventName'] = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
     $sel2['ParticipantEventType'] = $eventType;
-        $sel2['Contribution']         = CRM_Contribute_PseudoConstant::financialType( );
+    $sel2['Contribution'] = CRM_Contribute_PseudoConstant::financialType();
     $sel2['Relationship'] = $allRelationshipType;
 
     $sel2['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', FALSE, NULL);
@@ -291,9 +291,8 @@ class CRM_Custom_Form_Group extends CRM_Core_Form {
       'extends',
       ts('Used For'),
       array(
-        'onClick' => 'showHideStyle();',
         'name' => 'extends[0]',
-        'style' => 'vertical-align: top;',
+        'style' => 'vertical-align: top;'
       ),
       TRUE
     );
@@ -356,12 +355,8 @@ class CRM_Custom_Form_Group extends CRM_Core_Form {
     $this->addElement('checkbox', 'is_active', ts('Is this Custom Data Set active?'));
 
     // does this set have multiple record?
-    $multiple = $this->addElement('checkbox',
-      'is_multiple',
-      ts('Does this Custom Field Set allow multiple records?'),
-      NULL,
-      array('onclick' => "showRange();")
-    );
+    $multiple = $this->addElement('checkbox', 'is_multiple',
+      ts('Does this Custom Field Set allow multiple records?'), NULL);
 
     // $min_multiple = $this->add('text', 'min_multiple', ts('Minimum number of multiple records'), $attributes['min_multiple'] );
     // $this->addRule('min_multiple', ts('is a numeric field') , 'numeric');
@@ -422,10 +417,14 @@ class CRM_Custom_Form_Group extends CRM_Core_Form {
       $defaults['is_active'] = $defaults['collapse_display'] = 1;
       $defaults['style'] = 'Inline';
     }
-    elseif (!CRM_Utils_Array::value('max_multiple', $defaults) && !$this->_isGroupEmpty) {
+    elseif (empty($defaults['max_multiple']) && !$this->_isGroupEmpty) {
       $this->assign('showMaxMultiple', FALSE);
     }
 
+    if (($this->_action & CRM_Core_Action::UPDATE) && $defaults['is_multiple']) {
+      $defaults['collapse_display'] = 0;
+    }
+
     if (isset($defaults['extends'])) {
       $extends = $defaults['extends'];
       unset($defaults['extends']);
@@ -528,7 +527,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form {
   /*
    * Function to return a formatted list of relationship name.
    * @param $list array array of relationship name.
-   * @static 
+   * @static
    * return array array of relationship name.
    */
   static function getFormattedList(&$list) {