0

我在几个视图中使用了 Form Helper 类,我的行为非常奇怪。

例如,这是一个非常简单的视图:

<div class="users index">
    <h2>Users</h2>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th>id</th>
            <th>name</th>
            <th>username</th>
            <th>email</th>
            <th>role</th>
            <th class="actions">Actions</th>
        </tr>
        <?php
        $i = 0;
        foreach ($users as $user):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
            ?>
            <tr<?php echo $class; ?>>
                <td><?php echo $user['User']['id']; ?>&nbsp;</td>
                <td><?php echo $user['User']['name']; ?>&nbsp;</td>
                <td><?php echo $user['User']['username']; ?>&nbsp;</td>
                <td><?php echo $user['User']['email']; ?>&nbsp;</td>
                <td><?php echo "Role" ?>&nbsp;</td>
                <td class="actions">
                    <?php echo $this->Html->link('View', array('action' => 'view', $user['User']['id'])); ?>
                    <?php echo $this->Html->link('Edit', array('action' => 'edit', $user['User']['id'])); ?>
                    <?php echo $this->Form->postLink('Delete', array('action' => 'delete', $user['User']['id']), array('confirm' => 'Are you sure you want to delete this user?')); ?>
                </td>
            </tr>
        <?php endforeach; ?>
    </table>
</div>

如果用户数组有超过 5 条记录,我会在</最后得到一个非常奇怪的字符串,就在标签之前。

在使用大型表单时,我注意到了同样的行为。数场之后,那条奇怪的绳子又出现了。

我可以测试任何东西来确定问题。

谢谢

4

0 回答 0