Hello. I have a loop that creates multiple check boxes with the same name.
foreach ($openTickets as $ticketId)
{
$checkbox = new Check('id-'.$ticketId['TicketId'], array("name" => "tickets[]", "id" => 'id-'.$ticketId['TicketId'] , "value" => $ticketId['TicketId']));
$checkbox->addValidators(array(
new PresenceOf(array(
"message" => 'Please select a ticket'
))
)
);
$this->add($checkbox);
}
and on the phtml side.
foreach ($openTickets as $ticket) {?>
<tr >
<td>
<?php echo $form->render('id-'.$ticket['TicketId'])?>
</td>
<td><?php echo $ticket['DateCreatedDifference']; ?></td>
</tr>
<?php }?>
I am trying to force at least one checkbox to be checked. How do I achieve this.
Post fixed. Please read the Markdown FAQ for properly formatting code.