From 633ce2862e69db4a242721655bd13c00f3663b4c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 5 Oct 2021 19:47:29 -0400 Subject: [PATCH] Fix possibly unefined $form variables in smarty templates Referencing a property of the $form in smarty is almost always going to be undefined if it hasn't been set on the form, so this fixes a bad pattern of not using empty() to guard against e-notices. --- .../CRM/Event/Cart/Form/Checkout/Payment.tpl | 8 +++--- .../Search/Custom/MultipleValuesCriteria.tpl | 6 ++-- templates/CRM/Activity/Form/Search/Common.tpl | 6 ++-- templates/CRM/Admin/Form/Navigation.tpl | 2 +- templates/CRM/Admin/Form/PaymentProcessor.tpl | 28 +++++++++---------- .../CRM/Admin/Form/Preferences/Display.tpl | 2 +- templates/CRM/Admin/Form/PreferencesDate.tpl | 2 +- .../CRM/Admin/Form/Setting/Localization.tpl | 6 ++-- templates/CRM/Admin/Form/Setting/UF.tpl | 2 +- templates/CRM/Campaign/Form/ResultOptions.tpl | 2 +- templates/CRM/Case/Form/Activity.tpl | 2 +- templates/CRM/Case/Form/ActivityTab.tpl | 2 +- templates/CRM/Case/Form/Case.tpl | 6 ++-- templates/CRM/Case/Form/Search/Common.tpl | 2 +- .../CRM/Contact/Form/Edit/Individual.tpl | 8 +++--- .../CRM/Contact/Form/Inline/ContactName.tpl | 12 ++++---- templates/CRM/Contact/Form/OnBehalfOf.tpl | 2 +- .../CRM/Contact/Form/Search/BasicCriteria.tpl | 6 ++-- .../Form/Search/ContactSearchFields.tpl | 6 ++-- .../Form/Search/Criteria/DisplaySettings.tpl | 4 +-- .../Contact/Form/Search/Criteria/Location.tpl | 6 ++-- .../Form/Search/Criteria/SearchSettings.tpl | 2 +- .../CRM/Contact/Form/Task/AddToGroup.tpl | 2 +- templates/CRM/Contact/Form/Task/Email.tpl | 8 +++--- .../CRM/Contact/Form/Task/PDFLetterCommon.tpl | 4 +-- .../CRM/Contact/Form/Task/SaveSearch.tpl | 2 +- templates/CRM/Contact/Import/Form/Preview.tpl | 2 +- .../CRM/Contribute/Form/Contribution.tpl | 2 +- .../CRM/Contribute/Form/Contribution/Main.tpl | 6 ++-- .../Form/Contribution/OnBehalfOf.tpl | 4 +-- .../Form/ContributionPage/Amount.tpl | 4 +-- templates/CRM/Contribute/Page/Widget.tpl | 2 +- templates/CRM/Custom/Form/Field.tpl | 2 +- templates/CRM/Custom/Form/Optionfields.tpl | 4 +-- templates/CRM/Event/Form/EventFees.tpl | 2 +- .../CRM/Event/Form/ManageEvent/EventInfo.tpl | 6 ++-- .../Event/Form/ManageEvent/Registration.tpl | 6 ++-- .../CRM/Event/Form/Registration/Register.tpl | 4 +-- templates/CRM/Event/Form/SelfSvcTransfer.tpl | 2 +- templates/CRM/Event/Form/Task/AddToGroup.tpl | 2 +- templates/CRM/Export/Form/Select.tpl | 2 +- .../CRM/Financial/Form/BatchTransaction.tpl | 6 ++-- templates/CRM/Form/attachment.tpl | 2 +- templates/CRM/Form/body.tpl | 4 +-- templates/CRM/Group/Form/Edit.tpl | 2 +- templates/CRM/Mailing/Form/Search.tpl | 2 +- templates/CRM/Member/Form/MembershipBlock.tpl | 2 +- templates/CRM/Member/Form/Search/Common.tpl | 2 +- templates/CRM/PCP/Form/PCP.tpl | 2 +- templates/CRM/Pledge/Form/Pledge.tpl | 2 +- templates/CRM/Price/Form/Option.tpl | 4 +-- templates/CRM/Tag/Form/Edit.tpl | 6 ++-- templates/CRM/common/CMSUser.tpl | 4 +-- 53 files changed, 113 insertions(+), 113 deletions(-) diff --git a/ext/eventcart/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl b/ext/eventcart/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl index fba3a4770c45..60d841abc3fa 100644 --- a/ext/eventcart/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl +++ b/ext/eventcart/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl @@ -94,7 +94,7 @@ {if $payment_required == true} - {if $form.is_pay_later.label} + {if !empty($form.is_pay_later.label)}
{$form.is_pay_later.label}
{$form.is_pay_later.html} @@ -117,14 +117,14 @@ {/if} {/if} - {if $form.prox_distance.html} + {if !empty($form.prox_distance.html)}
{$form.prox_distance.label}
{$form.prox_distance.html} {$form.prox_distance_unit.html} diff --git a/templates/CRM/Contact/Form/Search/Criteria/SearchSettings.tpl b/templates/CRM/Contact/Form/Search/Criteria/SearchSettings.tpl index c835f8c2637b..15b93a640be4 100644 --- a/templates/CRM/Contact/Form/Search/Criteria/SearchSettings.tpl +++ b/templates/CRM/Contact/Form/Search/Criteria/SearchSettings.tpl @@ -3,7 +3,7 @@ {$form.operator.label} {help id="id-search-operator"}
{$form.operator.html} - {if $form.deleted_contacts}{$form.deleted_contacts.html} {$form.deleted_contacts.label}{/if} + {if !empty($form.deleted_contacts)}{$form.deleted_contacts.html} {$form.deleted_contacts.label}{/if}
diff --git a/templates/CRM/Contact/Form/Task/AddToGroup.tpl b/templates/CRM/Contact/Form/Task/AddToGroup.tpl index 24902aabd884..76182b231e83 100644 --- a/templates/CRM/Contact/Form/Task/AddToGroup.tpl +++ b/templates/CRM/Contact/Form/Task/AddToGroup.tpl @@ -33,7 +33,7 @@ {$form.description.label} {$form.description.html} - {if $form.group_type} + {if !empty($form.group_type)} {$form.group_type.label} {$form.group_type.html} diff --git a/templates/CRM/Contact/Form/Task/Email.tpl b/templates/CRM/Contact/Form/Task/Email.tpl index 9e21ef1faea6..c9b9b138a028 100644 --- a/templates/CRM/Contact/Form/Task/Email.tpl +++ b/templates/CRM/Contact/Form/Task/Email.tpl @@ -26,14 +26,14 @@ {$form.to.html} {help id="id-to_email" file="CRM/Contact/Form/Task/Email.hlp"} - + {$form.cc_id.label} {$form.cc_id.html} - + {$form.bcc_id.label} {$form.bcc_id.html} @@ -44,8 +44,8 @@ diff --git a/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl b/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl index 864fedeb6daa..acdbc46ac969 100644 --- a/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl +++ b/templates/CRM/Contact/Form/Task/PDFLetterCommon.tpl @@ -8,7 +8,7 @@ +--------------------------------------------------------------------+ *} {*common template for compose PDF letters*} -{if $form.template.html} +{if !empty($form.template.html)} - {if $form.campaign_id} + {if !empty($form.campaign_id)} diff --git a/templates/CRM/Contact/Form/Task/SaveSearch.tpl b/templates/CRM/Contact/Form/Task/SaveSearch.tpl index 5bcd911eeef4..dbbd2477dd26 100644 --- a/templates/CRM/Contact/Form/Task/SaveSearch.tpl +++ b/templates/CRM/Contact/Form/Task/SaveSearch.tpl @@ -34,7 +34,7 @@ - {if $form.group_type} + {if !empty($form.group_type)} diff --git a/templates/CRM/Contact/Import/Form/Preview.tpl b/templates/CRM/Contact/Import/Form/Preview.tpl index 15b30f1fbc27..e899d3daf42d 100644 --- a/templates/CRM/Contact/Import/Form/Preview.tpl +++ b/templates/CRM/Contact/Import/Form/Preview.tpl @@ -102,7 +102,7 @@ {* Existing Group *} -
+
{$form.groups.label}
diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 3be6ebb19aec..2d1724fc20ca 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -228,7 +228,7 @@
{/if} - {if $form.payment_processor_id} + {if !empty($form.payment_processor_id)} {/if}
@@ -23,7 +23,7 @@ {$form.subject.label} {$form.subject.html}
{$form.campaign_id.label} {$form.campaign_id.html}{$form.description.label} {$form.description.html}
{$form.group_type.label} {$form.group_type.html}
{$form.payment_processor_id.label} * {$form.payment_processor_id.html}
diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 2aba706f965b..7ae9f08092a5 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -135,7 +135,7 @@ {/if} {/crmRegion} - {if $form.is_recur} + {if !empty($form.is_recur)}
 
@@ -199,7 +199,7 @@
{$honor_block_text}
- {if $form.soft_credit_type_id.html} + {if !empty($form.soft_credit_type_id.html)}
{$form.soft_credit_type_id.html} @@ -256,7 +256,7 @@ {* end of ccid loop *} {/if} - {if $form.payment_processor_id.label} + {if !empty($form.payment_processor_id.label)} {* PP selection only works with JS enabled, so we hide it initially *}