Skip to content

Commit

Permalink
CIVIELECT-53 Use empty instead of count to avoid TypeErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
agileware-fj authored and agileware-dev committed Feb 20, 2024
1 parent eaed899 commit a54befd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CRM/Elections/Page/ElectionCandidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function removeNonRequiredPositions(&$positionsWithNominations) {
}

foreach ($positionsWithNominations as $index => $positionsWithNomination) {
if (count($positionsWithNomination['nominations']) == 0) {
if (empty($positionsWithNomination['nominations'])) {
$positionsToRemove[] = $index;
}
}
Expand Down
13 changes: 8 additions & 5 deletions templates/CRM/Elections/Page/ViewElectionBlocks/nominations.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
Existing Nominations
{/if}
</h2>
{if $nominations|@count == 0 and $positions|@count == 0}
{if empty($nominations) and empty($positions)}
<p class="no-result-message">Positions are not added yet to be nominated.</p>
{/if}

{if !empty($nominations)}
{foreach from = $nominations key = k item = nomination}
<div class="crm-election-position-nominations-block">

Expand All @@ -18,7 +19,8 @@
{/if}

<h3>{$positionKey} for {$nomination.name}</h3>
{if $nomination.nominations|@count == 0 and !$election->advertiseCandidatesStarted}

{if empty($nomination.nominations) and !$election->advertiseCandidatesStarted}
<p>There are no existing nominations</p>
{/if}
{assign var="candidatesCount" value=0}
Expand Down Expand Up @@ -71,11 +73,12 @@

{/foreach}
</div>
{if $candidatesCount == 0 and $election->advertiseCandidatesStarted}
{if empty($candidatesCount) and $election->advertiseCandidatesStarted}
<p>There are no eligible candidates.</p>
{/if}
{if $candidatesCount == 0 and !$election->advertiseCandidatesStarted and $nomination.nominations|@count != 0}
{if empty($candidatesCount) and !$election->advertiseCandidatesStarted and !empty($nomination.nominations)}
<p>There are no eligible nominations.</p>
{/if}
</div><div class="clearfix"></div>
{/foreach}
{/foreach}
{/if}

0 comments on commit a54befd

Please sign in to comment.