開発メモ

開発用のメモです。

cakephp view ソート機能つき一覧

<table class="users">
    <thead>
        <tr>
            <th rowspan="2" class="column-1"><?= $this->Paginator->sort("User.id", "ID")?></th>
            <th rowspan="2" class="column-2"><?= $this->Paginator->sort("User.name", "Name")?></th>
            <th rowspan="2" class="column-3"><?= $this->Paginator->sort("User.modified", "Modified")?></th>
            <th rowspan="2" class="column-4"><?= ucfirst("l")?></th>
            <th rowspan="2" class="column-5"><?= ucfirst("e")?></th>
            <th rowspan="2" class="column-6"><?= ucfirst("a")?></th>
            <th colspan="2" class="column-7"><?= ucfirst("Control")?></th>
        </tr>
        <tr>
            <th class="column-7"><?= ucfirst("Edit")?></th>
            <th class="column-8"><?= ucfirst("Detail")?></th>
        </tr>
    </thead>
    <tbody>
        <? foreach ($this->request->list as $key=>$data) { ?>
        <tr>
            <td class="column-1" nowrap="nowrap"><?= $data["User"]["id"]?></td>
            <td class="column-2" nowrap="nowrap"><?= $data["User"]["name"]?></td>
            <td class="column-3" nowrap="nowrap"><?= $data["User"]["modified"]?></td>
            <td class="column-4" nowrap="nowrap"><?= $data["User"]["locked"] == '1' ? '' : "&nbsp;" ?></td>
            <td class="column-5" nowrap="nowrap"><?= $data["User"]["enabled"] == '1' ? '' : "&nbsp;" ?></td>
            <td class="column-6" nowrap="nowrap"><?= $this->Form->checkbox("User.".$key.".id", array("hiddenField"=>false))?></td>
            <td class="column-7" nowrap="nowrap">
                <?= $this->Html->link("編集", $this->Form->url(array("action"=>"edit", $data["User"]["id"]))) ?>
            </td>
            <td class="column-8" nowrap="nowrap">
                <?= $this->Html->link("確認", $this->Form->url(array("action"=>"detile", $data["User"]["id"]))) ?>
            </td>
        </tr>
        <? } ?>
    </tbody>
</table>
Twitter: @asahina_alice