I want to get the checkboxes from a table in a view module, but I can't get it to work. This is the table:
<form action="" method="post">
<TABLE id="dt_basic" class="table table-striped table-bordered table-hover dataTable">
<THEAD>
<TR>
<TH></TH>
<TH>ID</TH>
<TH>Client</TH>
<TH>User</TH>
<TH>Role</TH>
<TH>Projects</TH>
</TR>
</THEAD>
<TBODY>
<?php
/* @var $item Admin\Model\User */
foreach ($this->users as $item) {
?>
<TR>
<TD class='admin'><input type="checkbox" name="users[<?php echo $item->id; ?>]" value=<?php echo $item->id; ?> checked/></TD>
<TD class='admin c'><?= $item->id ?></TD>
<TD class='admin'><?= $item->getClientObject() ?></TD>
<TD class='admin'>
<img src="<?= $item->getAvatarPath() ?>" alt="me" class="online avatar"/>
<a title='details'
href='/admin/user/detail/id/<?= $item->id ?>'><?= $item->name . " " . $item->surname ?> </a>
</TD>
<TD class='admin'><?= $item->getRoleObject() ?></TD>
<TD class='admin'>
<a title='projects' class='btn btn-default btn-sm'
href='/admin/user/project/id/<?= $item->id ?>'><i
class='fa fa-icon-fix fa-briefcase'></i></a>
<?
foreach ($this->projects[$item->id] as $i => $project) {
echo $project->getName();
if ($i != sizeof($this->projects[$item->id]) - 1)
echo " • ";
}
?>
</TD>
</TR>
<?php
}
?>
</TBODY>
</TABLE>
</form>
The whole .phtml
: http://pastebin.com/8paJZgjb
I want to get the users[]
array and use its elements inside the controller, but I can't find a way to get it. Here's what I've tried so far:
if (!empty($_POST["users"])) {
foreach (($_POST["users"]) as $selectedUsers) {
$users = $this->getUserTable()->fetchAll(false, "id=" . $selectedUsers);
}
} else {
$this->cache->error = "Please choose at least one user.";
return $this->view;
}
The whole function: http://pastebin.com/pE4afemx
...but apparently it's empty.
var_dump
shows the elements from the mailing form, but no sign of the users:
array (size=2)
'subject' => string 'hello' (length=5)
'message' => string 'message' (length=7)
Any suggestions ?