コントローラで設定したエラー数とエラーメッセージをビューにて表示する。
Formヘルパーのerrorメソッドを使えば、エラーメッセージを取ることはできるが、コントローラで独自のメッセージを設定したいためこのようにした。
<?php if(!empty($errorcount) && $errorcount > 0) { echo '<table cellpadding="5" class="userregistertbl"><tr><td class="userregistertblerror">'; foreach ($errormsgs as $value) { echo "・$value<br>"; } echo '</td></tr></table>'; } ?> <?php echo $form->create('User', array('url' => '/member/register', 'type' => 'post')); ?> <table cellpadding="5" class="userregistertbl"> <tr> <td class="userregistertbltitle">MOSHIMORE ID</td> <td class="userregistertblinfo"><?php echo $form->text('username', array('class' => 'useridpassbox')); ?> 6〜12文字の半角英数</td> </tr> <tr> <td class="userregistertbltitle">パスワード</td> <td class="userregistertblinfo"><?php echo $form->password('password1', array('value' => '', 'class' => 'useridpassbox')); ?> 6〜32文字の半角英数</td> </tr> <tr> <td class="userregistertbltitle">パスワード(確認)</td> <td class="userregistertblinfo"><?php echo $form->password('password2', array('value' => '', 'class' => 'useridpassbox')); ?></td> </tr> <tr> <td class="userregistertbltitle">メールアドレス</td> <td class="userregistertblinfo"><?php echo $form->text('mailaddress', array('class' => 'usermailbox')); ?> 例:moshimore@example.com</td> </tr> <tr> <td class="userregistertbltitle">生年月日</td> <td class="userregistertblinfo"><?php echo $form->year('birthday', 1900, 2009, $this->data['User']['birthday']['year'], null, false) ?> 年 <?php echo $form->month('birthday', $this->data['User']['birthday']['month'], null, false) ?> 月 <?php echo $form->day('birthday', $this->data['User']['birthday']['day'], null, false) ?> 日</td> </tr> </table> <table class="userregisterconfirmtbl"> <tr> <td class="userregisterconfirminfo">以下のサービス利用規約をお読みになり、全ての内容に同意の上、ご登録ください。<?php echo $form->submit('サービス利用規約に同意して登録する'); ?></td> </tr> </table> <?php echo $form->end(); ?>
