回答編集履歴
2
修正
answer
CHANGED
@@ -21,5 +21,6 @@
|
|
21
21
|
if(!$this->Contact->validates()){
|
22
22
|
$this->Session->setFlash('バリデート失敗');
|
23
23
|
$this->render('index');
|
24
|
+
return;
|
24
25
|
}
|
25
26
|
```
|
1
追記
answer
CHANGED
@@ -11,4 +11,15 @@
|
|
11
11
|
もしくは、indexとconfirmアクションは一つにまとめて、validateに成功したら、confirm.ctpで描画。validateに失敗したらindex.ctpを描画するという方法もありますが。以下のようにやるとaction名と異なるctpファイルを指定できます。
|
12
12
|
```php
|
13
13
|
$this->render('confirm');
|
14
|
+
```
|
15
|
+
|
16
|
+
**(追記)**
|
17
|
+
今回の場合は、confirmアクションで、バリデートに失敗したらindexビューを描画するのがいいかもしれません。
|
18
|
+
```php
|
19
|
+
```php
|
20
|
+
$this->Contact->set($this->request->data);
|
21
|
+
if(!$this->Contact->validates()){
|
22
|
+
$this->Session->setFlash('バリデート失敗');
|
23
|
+
$this->render('index');
|
24
|
+
}
|
14
25
|
```
|