I am using codeigniter 3.16 on an Ubuntu 14.04 server, with apache 2.6 and php 5.6. I have created a multipart form to upload several files and check (or not) a group of checkboxes. My view looks something like:
<form id="creation_form" name="creation_form" class="form-horizontal" action="<?=(isset($edit)?site_url('admin/Projects/edit/').$project->ID:site_url('admin/Projects/create'))?>" method="POST" enctype="multipart/form-data">
// ...
<?php foreach ($users as $user) { ?>
<tr>
<td><input type="checkbox" name="users[]" value="<?= $user->ID ?>" <?=(isset($edit) && isset($project_users[$user->ID])?"checked":"")?>/></td>
<td><?= $user->name ?></td>
<td><?= $user->surname ?></td>
<td><?= $user->email ?></td>
</tr>
<?php } ?>
</form>
My controller gets the values of the checked checkboxes with this code:
$users_ids = $this->input->post("users");
if (!isset($users_ids) || sizeof($users_ids) == 0) {
$error_msg = "Assign at least one user to the project";
}
But it is returning nothing, $users_ids
is empty no matters how many checkboxes I check, and I am recovering other inputs like texts and files correctly but not the checkboxes.
Thank you all for your help,
Luis
Aucun commentaire:
Enregistrer un commentaire