Skip to content

Commit

Permalink
Teams module: Fix "Invalid argument supplied for foreach()"
Browse files Browse the repository at this point in the history
  • Loading branch information
blackcoder87 committed Jan 23, 2019
1 parent adcb2f3 commit 7966d8d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 45 deletions.
2 changes: 1 addition & 1 deletion application/modules/teams/controllers/admin/Index.php
Expand Up @@ -72,7 +72,7 @@ public function indexAction()
}
}

if ($this->getRequest()->getPost('saveTeams')) {
if ($this->getRequest()->getPost('saveTeams') && !empty($this->getRequest()->getPost('items'))) {
foreach ($this->getRequest()->getPost('items') as $i => $teamId) {
$teamsMapper->sort($teamId, $i);
}
Expand Down
86 changes: 42 additions & 44 deletions application/modules/teams/views/admin/index/index.php
@@ -1,59 +1,57 @@
<h1><?=$this->getTrans('manage') ?></h1>
<form class="form-horizontal" method="POST">
<?=$this->getTokenField() ?>
<div class="table-responsive">
<table class="table table-hover table-striped">
<colgroup>
<col class="icon_width" />
<col class="icon_width" />
<col class="icon_width" />
<col class="icon_width" />
<col />
</colgroup>
<thead>
<?php if (!empty($this->get('teams'))): ?>
<form class="form-horizontal" method="POST">
<?=$this->getTokenField() ?>
<div class="table-responsive">
<table class="table table-hover table-striped">
<colgroup>
<col class="icon_width" />
<col class="icon_width" />
<col class="icon_width" />
<col class="icon_width" />
<col />
</colgroup>
<thead>
<tr>
<th><?=$this->getCheckAllCheckbox('check_teams') ?></th>
<th></th>
<th></th>
<th></th>
<th><?=$this->getTrans('menuTeam') ?></th>
</tr>
</thead>
<tbody>
<?php if ($this->get('teams') != ''): ?>
<?php foreach ($this->get('teams') as $team): ?>
<tr>
<input type="hidden" name="items[]" value="<?=$team->getId() ?>" />
<td><?=$this->getDeleteCheckbox('check_teams', $team->getId()) ?></td>
<td><?=$this->getEditIcon(['action' => 'treat', 'id' => $team->getId()]) ?></td>
<td><?=$this->getDeleteIcon(['action' => 'del', 'id' => $team->getId()]) ?></td>
<td><i class="fa fa-sort"></i></td>
<td><?=$this->escape($team->getName()) ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
</thead>
<tbody>
<?php foreach ($this->get('teams') as $team): ?>
<tr>
<td colspan="5"><?=$this->getTrans('noCats') ?></td>
<input type="hidden" name="items[]" value="<?=$team->getId() ?>" />
<td><?=$this->getDeleteCheckbox('check_teams', $team->getId()) ?></td>
<td><?=$this->getEditIcon(['action' => 'treat', 'id' => $team->getId()]) ?></td>
<td><?=$this->getDeleteIcon(['action' => 'del', 'id' => $team->getId()]) ?></td>
<td><i class="fa fa-sort"></i></td>
<td><?=$this->escape($team->getName()) ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<div class="content_savebox">
<input type="hidden" class="content_savebox_hidden" name="action" value="" />
<div class="btn-group dropup">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<?=$this->getTrans('selected') ?> <span class="caret"></span>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="content_savebox">
<input type="hidden" class="content_savebox_hidden" name="action" value="" />
<div class="btn-group dropup">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<?=$this->getTrans('selected') ?> <span class="caret"></span>
</button>
<ul class="dropdown-menu listChooser" role="menu">
<li><a href="#" data-hiddenkey="delete"><?=$this->getTrans('delete') ?></a></li>
</ul>
</div>
<button type="submit" class="save_button btn btn-default" name="saveTeams" value="save">
<?=$this->getTrans('saveButton') ?>
</button>
<ul class="dropdown-menu listChooser" role="menu">
<li><a href="#" data-hiddenkey="delete"><?=$this->getTrans('delete') ?></a></li>
</ul>
</div>
<button type="submit" class="save_button btn btn-default" name="saveTeams" value="save">
<?=$this->getTrans('saveButton') ?>
</button>
</div>
</form>
</form>
<?php else: ?>
<?=$this->getTrans('noTeams') ?>
<?php endif; ?>

<script>
$('table tbody').sortable({
Expand Down

0 comments on commit 7966d8d

Please sign in to comment.