mardi 2 juin 2015

Zend Framework 2 checked checkbox if input value = 1

I'm doing a new module based on http://ift.tt/1iwohEJ and I have got one problem. How to make the checkbox checked if value = 1?

view/index.phtml

<?php

$title = 'Newsletter';
$this->headTitle($title);
?>

<h1>Newsletter</h1>
<p>Select users who are to receive the newsletter.</p>

<table class="table table-striped">
    <tr>
        <td width="80%"><strong>User_id</strong></td>
        <td width="10%" align="center"><strong>Yes/No</strong></td>
    </tr>
    <?php foreach ($newsletters as $newsletter) : ?>

        <tr>
            <td><?php echo $this->escapeHtml($newsletter->user_id); ?></td>
            <td align="center"><?php echo $this->escapeHtml($newsletter->wantNewsletter); ?> <input type="checkbox" name="wantNewsletter" value="<?php echo $this->escapeHtml($newsletter->wantNewsletter); ?>"></td>
        </tr>

    <?php endforeach; ?>
    <tr>
        <td colspan="2" align="right"><button>Zapisz</button></td>
    </tr>
</table>




Aucun commentaire:

Enregistrer un commentaire