Use array_key_exists instead of not empty in tpl
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 28 Jul 2023 03:18:56 +0000 (15:18 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 28 Jul 2023 03:18:56 +0000 (15:18 +1200)
templates/CRM/Core/Form/Field.tpl

index b2d5ba396bf597d56ba784eb2f7a59a3f8edd0af..83c244181aad0de5cdc0dc72eb1e67b20ba9e507 100644 (file)
@@ -7,15 +7,16 @@
  | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
 *}
-{if !empty($fieldSpec.template)}
+{if array_key_exists('template', $fieldSpec)}
   {include file=$fieldSpec.template}
 {else}
   <td class="label">{$form.$fieldName.label}
-    {if !empty($fieldSpec.help|smarty:nodefaults)}{assign var=help value=$fieldSpec.help}{help id=$help.id file=$help.file}{/if}
-    {if $action == 2 && !empty($fieldSpec.is_add_translate_dialog)}{include file='CRM/Core/I18n/Dialog.tpl' table=$entityTable field=$fieldName id=$entityID}{/if}
+    {if array_key_exists('help', $fieldSpec)}{assign var=help value=$fieldSpec.help}{help id=$help.id file=$help.file}{/if}
+    {if $action == 2 && array_key_exists('is_add_translate_dialog', $fieldSpec)}{include file='CRM/Core/I18n/Dialog.tpl' table=$entityTable field=$fieldName id=$entityID}{/if}
   </td>
-  <td>{if !empty($fieldSpec.pre_html_text)}{$fieldSpec.pre_html_text}{/if}{if $form.$fieldName.html}{$form.$fieldName.html}{else}{$fieldSpec.place_holder}{/if}{if !empty($fieldSpec.post_html_text)}{$fieldSpec.post_html_text}{/if}<br />
-    {if !empty($fieldSpec.description)}<span class="description">{$fieldSpec.description}</span>{/if}
-    {if !empty($fieldSpec.documentation_link)}{docURL page=$fieldSpec.documentation_link.page resource=$fieldSpec.documentation_link.resource}{/if}
+  <td>
+    {if array_key_exists('pre_html_text', $fieldSpec)}{$fieldSpec.pre_html_text}{/if}{if $form.$fieldName.html}{$form.$fieldName.html}{else}{$fieldSpec.place_holder}{/if}{if array_key_exists('post_html_text', $fieldSpec)}{$fieldSpec.post_html_text}{/if}<br />
+    {if array_key_exists('description', $fieldSpec)}<span class="description">{$fieldSpec.description}</span>{/if}
+    {if array_key_exists('documentation_link', $fieldSpec)}{docURL page=$fieldSpec.documentation_link.page resource=$fieldSpec.documentation_link.resource}{/if}
   </td>
 {/if}