fixed invaild html generate while adding additional blocks CRM-14937
authorkurund <kurund@civicrm.org>
Tue, 15 Jul 2014 18:56:43 +0000 (00:26 +0530)
committerkurund <kurund@civicrm.org>
Tue, 15 Jul 2014 18:56:43 +0000 (00:26 +0530)
----------------------------------------
* CRM-14937: CiviEvents: when using existing location on a new event, only the first phone number is loaded causing data loss on save
  https://issues.civicrm.org/jira/browse/CRM-14937

CRM/Event/Form/ManageEvent/Location.php
templates/CRM/Contact/Form/Edit/Phone.tpl
templates/CRM/Event/Form/ManageEvent/Location.tpl

index 2e03c1574d9cbb731de8bd2202ff5c02322f7980..6dcafef241951c8f941a4b0745c9dbfe38539421 100644 (file)
@@ -75,6 +75,14 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent {
    * @access public
    */
   function preProcess() {
+    //location blocks.
+    CRM_Contact_Form_Location::preProcess($this);
+
+    //skip rest of postpress when we are building additional email and phone blocks
+    if (!empty($this->_addBlockName)) {
+      return;
+    }
+
     parent::preProcess();
 
     $this->_values = $this->get('values');
@@ -92,9 +100,6 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent {
       CRM_Event_BAO_Event::retrieve($params, $this->_values);
       $this->set('values', $this->_values);
     }
-
-    //location blocks.
-    CRM_Contact_Form_Location::preProcess($this);
   }
 
   /**
index 1d859ce890d221a4fe35f08204883bea0a57ec17..aa65c03bcdb30080c0c78e6cbc20b5c43fbf7582 100644 (file)
 {* @var blockId Contains the current block id, and assigned in the CRM/Contact/Form/Location.php file *}
 
 {if !$addBlock}
-    <tr>
-  <td>{ts}Phone{/ts}</td>
-  <td>{ts}Phone Location{/ts}</td>
-  {if $className eq 'CRM_Contact_Form_Contact'}
-      <td colspan="2">{ts}Phone Type{/ts}</td>
+  <tr>
+    <td>{ts}Phone{/ts}</td>
+    {if $className eq 'CRM_Contact_Form_Contact'}
+    <td>{ts}Phone Location{/ts}</td>
+    {/if}
+    <td colspan="2">{ts}Phone Type{/ts}</td>
+    {if $className eq 'CRM_Contact_Form_Contact'}
       <td id="Phone-Primary" class="hiddenElement">{ts}Primary?{/ts}</td>
-  {/if}
-    </tr>
+    {/if}
+  </tr>
 {/if}
 <tr id="Phone_Block_{$blockId}">
-    <td>{$form.phone.$blockId.phone.html}&nbsp;&nbsp;{ts}ext.{/ts}&nbsp;{$form.phone.$blockId.phone_ext.html|crmAddClass:four}&nbsp;</td>
-    <td>{$form.phone.$blockId.location_type_id.html}</td>
-    <td colspan="2">{$form.phone.$blockId.phone_type_id.html}</td>
+  <td>{$form.phone.$blockId.phone.html}&nbsp;&nbsp;{ts}ext.{/ts}&nbsp;{$form.phone.$blockId.phone_ext.html|crmAddClass:four}&nbsp;</td>
+  {if $className eq 'CRM_Contact_Form_Contact'}
+  <td>{$form.phone.$blockId.location_type_id.html}</td>
+  {/if}
+  <td colspan="2">{$form.phone.$blockId.phone_type_id.html}</td>
+  {if $className eq 'CRM_Contact_Form_Contact'}
     <td align="center" id="Phone-Primary-html" {if $blockId eq 1}class="hiddenElement"{/if}>{$form.phone.$blockId.is_primary.1.html}</td>
-    {if $blockId gt 1}
-  <td><a href="#" title="{ts}Delete Phone Block{/ts}" onClick="removeBlock('Phone','{$blockId}'); return false;">{ts}delete{/ts}</a></td>
-    {/if}
+  {/if}
+  {if $blockId gt 1}
+    <td><a href="#" title="{ts}Delete Phone Block{/ts}" onClick="removeBlock('Phone','{$blockId}'); return false;">{ts}delete{/ts}</a></td>
+  {/if}
 </tr>
+
 {if !$addBlock}
 <tr>
-<td colspan="4">
-&nbsp;&nbsp;<a id='addPhone' href="#" title={ts}Add{/ts} onClick="buildAdditionalBlocks( 'Phone', '{$className}');return false;">{ts}Add another Phone number{/ts}</a>
-</td>
+  <td colspan="4">
+  &nbsp;&nbsp;<a id='addPhone' href="#" title={ts}Add{/ts} onClick="buildAdditionalBlocks( 'Phone', '{$className}');return false;">{ts}Add another Phone number{/ts}</a>
+  </td>
 </tr>
 {/if}
 
index 8dde0645e662253afa8e661a03525de7b72623c1..05fb5216e06de1e4ff23e97620537faaa4af9078 100644 (file)
         {ts}Use this form to configure the location and optional contact information for the event. This information will be displayed on the Event Information page. It will also be included in online registration pages and confirmation emails if these features are enabled.{/ts}
     </div>
 {/if}
-<div class="crm-block crm-form-block crm-event-manage-location-form-block">
+
 {if $addBlock}
 {include file="CRM/Contact/Form/Edit/$blockName.tpl"}
 {else}
+<div class="crm-block crm-form-block crm-event-manage-location-form-block">
 <div class="crm-submit-buttons">
    {include file="CRM/common/formButtons.tpl" location="top"}
 </div>