Fix some form notices on Contact Edit form new contact
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 8 Jun 2023 22:38:21 +0000 (10:38 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 8 Jun 2023 22:38:21 +0000 (10:38 +1200)
templates/CRM/Contact/Form/Edit/CommunicationPreferences.tpl

index 21099dd31945735d7945761ba4d7a69a84b52e54..5b469501c87607c349a8fe427a41d4928189f613 100644 (file)
   </div><!-- /.crm-accordion-header -->
 <div id="commPrefs" class="crm-accordion-body">
     <table class="form-layout-compressed" >
-        {if !empty($form.communication_style_id)}
-            <tr><td colspan='4'>
-                <span class="label">{$form.communication_style_id.label} {help id="id-communication_style" file="CRM/Contact/Form/Contact.hlp"}</span>
-                <span class="value">{$form.communication_style_id.html}</span>
-            </td><tr>
+        {if array_key_exists('communication_style_id', $form)}
+          <tr><td colspan='4'>
+            <span class="label">{$form.communication_style_id.label} {help id="id-communication_style" file="CRM/Contact/Form/Contact.hlp"}</span>
+            <span class="value">{$form.communication_style_id.html}</span>
+          </td><tr>
         {/if}
         <tr>
-            {if !empty($form.email_greeting_id)}
-                <td>{$form.email_greeting_id.label}</td>
-            {/if}
-            {if !empty($form.postal_greeting_id)}
-                <td>{$form.postal_greeting_id.label}</td>
-            {/if}
-            {if !empty($form.addressee_id)}
-                <td>{$form.addressee_id.label}</td>
-            {/if}
-      {if !empty($form.email_greeting_id) OR !empty($form.postal_greeting_id) OR !empty($form.addressee_id)}
-                <td>&nbsp;&nbsp;{help id="id-greeting" file="CRM/Contact/Form/Contact.hlp"}</td>
-      {/if}
+          {if array_key_exists('email_greeting_id', $form)}
+            <td>{$form.email_greeting_id.label}</td>
+          {/if}
+          {if array_key_exists('postal_greeting_id', $form)}
+            <td>{$form.postal_greeting_id.label}</td>
+          {/if}
+          {if array_key_exists('addressee_id', $form)}
+            <td>{$form.addressee_id.label}</td>
+          {/if}
+          {if array_key_exists('email_greeting_id', $form) OR array_key_exists('postal_greeting_id', $form) OR array_key_exists('addressee_id', $form)}
+            <td>&nbsp;&nbsp;{help id="id-greeting" file="CRM/Contact/Form/Contact.hlp"}</td>
+          {/if}
         </tr>
         <tr>
-            {if !empty($form.email_greeting_id)}
+            {if array_key_exists('email_greeting_id', $form)}
                 <td>
                     <span id="email_greeting" {if !empty($email_greeting_display) and $action eq 2} class="hiddenElement"{/if}>{$form.email_greeting_id.html|crmAddClass:big}</span>
                     {if !empty($email_greeting_display) and $action eq 2}
@@ -47,7 +47,7 @@
                     {/if}
                 </td>
             {/if}
-            {if !empty($form.postal_greeting_id)}
+            {if array_key_exists('postal_greeting_id', $form)}
                 <td>
                     <span id="postal_greeting" {if !empty($postal_greeting_display) and $action eq 2} class="hiddenElement"{/if}>{$form.postal_greeting_id.html|crmAddClass:big}</span>
                     {if !empty($postal_greeting_display) and $action eq 2}
@@ -57,7 +57,7 @@
                     {/if}
                 </td>
             {/if}
-            {if !empty($form.addressee_id)}
+            {if array_key_exists('addressee_id', $form)}
                 <td>
                     <span id="addressee" {if !empty($addressee_display) and $action eq 2} class="hiddenElement"{/if}>{$form.addressee_id.html|crmAddClass:big}</span>
                     {if !empty($addressee_display) and $action eq 2}
             {/if}
         </tr>
         <tr id="greetings1" class="hiddenElement">
-            {if !empty($form.email_greeting_custom)}
-                <td><span id="email_greeting_id_label" class="hiddenElement">{$form.email_greeting_custom.label}</span></td>
-            {/if}
-            {if !empty($form.postal_greeting_custom)}
-                <td><span id="postal_greeting_id_label" class="hiddenElement">{$form.postal_greeting_custom.label}</span></td>
-            {/if}
-            {if !empty($form.addressee_custom)}
-                <td><span id="addressee_id_label" class="hiddenElement">{$form.addressee_custom.label}</span></td>
-            {/if}
+          {if array_key_exists('email_greeting_custom', $form)}
+            <td><span id="email_greeting_id_label" class="hiddenElement">{$form.email_greeting_custom.label}</span></td>
+          {/if}
+          {if array_key_exists('postal_greeting_custom', $form)}
+            <td><span id="postal_greeting_id_label" class="hiddenElement">{$form.postal_greeting_custom.label}</span></td>
+          {/if}
+          {if array_key_exists('addressee_custom', $form)}
+            <td><span id="addressee_id_label" class="hiddenElement">{$form.addressee_custom.label}</span></td>
+          {/if}
         </tr>
         <tr id="greetings2" class="hiddenElement">
-            {if !empty($form.email_greeting_custom)}
-                <td><span id="email_greeting_id_html" class="hiddenElement">{$form.email_greeting_custom.html|crmAddClass:big}</span></td>
-            {/if}
-             {if !empty($form.postal_greeting_custom)}
-                <td><span id="postal_greeting_id_html" class="hiddenElement">{$form.postal_greeting_custom.html|crmAddClass:big}</span></td>
-            {/if}
-            {if !empty($form.addressee_custom)}
-                <td><span id="addressee_id_html" class="hiddenElement">{$form.addressee_custom.html|crmAddClass:big}</span></td>
-            {/if}
+          {if array_key_exists('email_greeting_custom', $form)}
+            <td><span id="email_greeting_id_html" class="hiddenElement">{$form.email_greeting_custom.html|crmAddClass:big}</span></td>
+          {/if}
+           {if array_key_exists('postal_greeting_custom', $form)}
+            <td><span id="postal_greeting_id_html" class="hiddenElement">{$form.postal_greeting_custom.html|crmAddClass:big}</span></td>
+          {/if}
+          {if array_key_exists('addressee_custom', $form)}
+            <td><span id="addressee_id_html" class="hiddenElement">{$form.addressee_custom.html|crmAddClass:big}</span></td>
+          {/if}
         </tr>
         <tr>
           {foreach key=key item=item from=$commPreference}