PHP
1// /Template/Hoges/hoge.php 2echo $this->Form->input('mail', [ 3 'templates' => [ 4 'label' => '<th>メールアドレス<span class="required">必須</span></th>', 5 'input' => '<td><input type="{{type}}" name="{{name}}"{{attrs}} class="form-control" /></td>', 6 'inputContainer' => '<tr>{{content}}</tr>', 7 ], 8 'required' => false, 9 ]);
PHP
1// HogesTable.php 2$validator 3 ->requirePresence('mail', 'create') 4 ->notEmpty('mail','必須');
HTML
1<!--生成されるHTML--> 2<tr> 3<th>メールアドレス</th> 4<td><input type="text" name="mail" id="mail" class="form-control" /></td> 5</tr>
↓バリデーションエラーの場合に以下のように生成したいです。
HTML
1<tr> 2<th>メールアドレス</th> 3<td> 4<input type="text" name="mail" id="mail" class="form-control" /> 5<div class="error">エラーメッセージ</div> 6</td> 7</tr>
######現状
HTML
1<div class="input text error"></div> 2<div class="error-message">必須</div> 3<table> 4<tbody> 5<tr> 6<th>メールアドレス</th> 7<td> 8<input type="text" name="mail" id="mail" class="form-control" /> 9</td> 10</tr> 11</tbody> 12</table>
宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/08 04:14