From a54befdadbe731442b019ffba427e9721f341724 Mon Sep 17 00:00:00 2001 From: Francis Whittle Date: Tue, 20 Feb 2024 15:26:25 +1100 Subject: [PATCH] CIVIELECT-53 Use empty instead of count to avoid TypeErrors --- CRM/Elections/Page/ElectionCandidate.php | 2 +- .../Page/ViewElectionBlocks/nominations.tpl | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CRM/Elections/Page/ElectionCandidate.php b/CRM/Elections/Page/ElectionCandidate.php index 979326d..29d18d2 100644 --- a/CRM/Elections/Page/ElectionCandidate.php +++ b/CRM/Elections/Page/ElectionCandidate.php @@ -76,7 +76,7 @@ private function removeNonRequiredPositions(&$positionsWithNominations) { } foreach ($positionsWithNominations as $index => $positionsWithNomination) { - if (count($positionsWithNomination['nominations']) == 0) { + if (empty($positionsWithNomination['nominations'])) { $positionsToRemove[] = $index; } } diff --git a/templates/CRM/Elections/Page/ViewElectionBlocks/nominations.tpl b/templates/CRM/Elections/Page/ViewElectionBlocks/nominations.tpl index 2df4bff..e6e55f2 100644 --- a/templates/CRM/Elections/Page/ViewElectionBlocks/nominations.tpl +++ b/templates/CRM/Elections/Page/ViewElectionBlocks/nominations.tpl @@ -5,10 +5,11 @@ Existing Nominations {/if} -{if $nominations|@count == 0 and $positions|@count == 0} +{if empty($nominations) and empty($positions)}

Positions are not added yet to be nominated.

{/if} +{if !empty($nominations)} {foreach from = $nominations key = k item = nomination}
@@ -18,7 +19,8 @@ {/if}

{$positionKey} for {$nomination.name}

- {if $nomination.nominations|@count == 0 and !$election->advertiseCandidatesStarted} + + {if empty($nomination.nominations) and !$election->advertiseCandidatesStarted}

There are no existing nominations

{/if} {assign var="candidatesCount" value=0} @@ -71,11 +73,12 @@ {/foreach}
- {if $candidatesCount == 0 and $election->advertiseCandidatesStarted} + {if empty($candidatesCount) and $election->advertiseCandidatesStarted}

There are no eligible candidates.

{/if} - {if $candidatesCount == 0 and !$election->advertiseCandidatesStarted and $nomination.nominations|@count != 0} + {if empty($candidatesCount) and !$election->advertiseCandidatesStarted and !empty($nomination.nominations)}

There are no eligible nominations.

{/if}
-{/foreach} \ No newline at end of file +{/foreach} +{/if} \ No newline at end of file