質問編集履歴
5
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,35 @@
|
|
20
20
|
|
21
21
|
```
|
22
22
|
|
23
|
+
public function register($lang = null)
|
24
|
+
|
25
|
+
{
|
26
|
+
|
27
|
+
$lang = ($lang === null) ? 'ja' : $lang;
|
28
|
+
|
29
|
+
$dataMaster = new DataMaster();
|
30
|
+
|
31
|
+
$this->set('Countries', $dataMaster->getAllCountries($lang));
|
32
|
+
|
33
|
+
$this->set('Languages', $dataMaster->getAllLanguages($lang));
|
34
|
+
|
35
|
+
$this->set('Genders', $dataMaster->getAllGenders($lang));
|
36
|
+
|
37
|
+
if ($lang === 'ja') {
|
38
|
+
|
39
|
+
$this->set('Prefectures', $dataMaster->getAllPrefectures($lang));
|
40
|
+
|
41
|
+
}else{
|
42
|
+
|
43
|
+
$this->set('Prefectures', false);
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
$member = $this->Member->newEntity();
|
50
|
+
|
23
|
-
if ($this->request->is('post')) {
|
51
|
+
if ($this->request->is('post')) {
|
24
52
|
|
25
53
|
$member = $this->Member->newEntity($this->request->data, [
|
26
54
|
|
@@ -30,12 +58,6 @@
|
|
30
58
|
|
31
59
|
if ($member->errors()){
|
32
60
|
|
33
|
-
$this->set(compact('member'));
|
34
|
-
|
35
|
-
$this->set('_serialize', ['member']);
|
36
|
-
|
37
|
-
// $this->Flash->error($member->errors('member_detail')[0]['nickname']['ngword']);
|
38
|
-
|
39
61
|
$this->Flash->error(__('The member could not be saved. Please, try again.'));
|
40
62
|
|
41
63
|
}
|
@@ -50,6 +72,12 @@
|
|
50
72
|
|
51
73
|
}
|
52
74
|
|
75
|
+
$this->set(compact('member'));
|
76
|
+
|
77
|
+
$this->set('_serialize', ['member']);
|
78
|
+
|
79
|
+
}
|
80
|
+
|
53
81
|
```
|
54
82
|
|
55
83
|
|
@@ -184,7 +212,7 @@
|
|
184
212
|
|
185
213
|
<div class="member form large-9 medium-8 columns content">
|
186
214
|
|
187
|
-
<?= $this->Form->create(
|
215
|
+
<?= $this->Form->create($member) ?>
|
188
216
|
|
189
217
|
<fieldset>
|
190
218
|
|
@@ -194,20 +222,6 @@
|
|
194
222
|
|
195
223
|
<?php
|
196
224
|
|
197
|
-
// if (isset($ValidationError) && is_array($ValidationError)){
|
198
|
-
|
199
|
-
// foreach ($ValidationError as $key => $values){
|
200
|
-
|
201
|
-
// foreach ($values as $value){
|
202
|
-
|
203
|
-
// echo '<p class="error">' . $value . '</p>';
|
204
|
-
|
205
|
-
// }
|
206
|
-
|
207
|
-
// }
|
208
|
-
|
209
|
-
// }
|
210
|
-
|
211
225
|
echo $this->Form->input('member_detail.0.nickname', ['label' => __('なまえ')]);
|
212
226
|
|
213
227
|
echo $this->Form->input('member_detail.0.gender', ['label' => __('性別'), 'type' => 'radio', 'options' => $Genders]);
|
4
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,139 +20,231 @@
|
|
20
20
|
|
21
21
|
```
|
22
22
|
|
23
|
+
if ($this->request->is('post')) {
|
24
|
+
|
25
|
+
$member = $this->Member->newEntity($this->request->data, [
|
26
|
+
|
27
|
+
'associated' => ['MemberDetail']
|
28
|
+
|
29
|
+
]);
|
30
|
+
|
31
|
+
if ($member->errors()){
|
32
|
+
|
33
|
+
$this->set(compact('member'));
|
34
|
+
|
35
|
+
$this->set('_serialize', ['member']);
|
36
|
+
|
37
|
+
// $this->Flash->error($member->errors('member_detail')[0]['nickname']['ngword']);
|
38
|
+
|
39
|
+
$this->Flash->error(__('The member could not be saved. Please, try again.'));
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
if ($this->Member->save($member)) {
|
44
|
+
|
45
|
+
$this->Flash->success(__('The member has been saved.'));
|
46
|
+
|
47
|
+
return $this->redirect(['action' => 'login']);
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
$ngWords = $this->ngwords->find();
|
60
|
+
|
61
|
+
foreach ($ngWords as $row){
|
62
|
+
|
63
|
+
$word[] = $row->word;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
$this->set('ngwords', $word);
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
Table
|
74
|
+
|
75
|
+
```
|
76
|
+
|
23
|
-
public function in
|
77
|
+
public function validationDefault(Validator $validator)
|
24
78
|
|
25
79
|
{
|
26
80
|
|
27
|
-
|
81
|
+
$validator
|
28
|
-
|
82
|
+
|
29
|
-
|
83
|
+
->allowEmpty('id', 'create');
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
$validator
|
88
|
+
|
89
|
+
->allowEmpty('nickname')
|
90
|
+
|
91
|
+
->add('nickname', [
|
92
|
+
|
93
|
+
'ngword' => [
|
94
|
+
|
95
|
+
'rule' => function($value, $context){
|
96
|
+
|
97
|
+
return !TableRegistry::get('ng_word')->exists(["'{$value}' LIKE concat('%', word, '%')"]);
|
98
|
+
|
99
|
+
},
|
100
|
+
|
101
|
+
'massage' => '「おなまえ」に不適切な語句が含まれています'
|
102
|
+
|
103
|
+
]
|
104
|
+
|
105
|
+
]);
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
$validator
|
110
|
+
|
111
|
+
->integer('gender')
|
112
|
+
|
113
|
+
->notEmpty('gender');
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
$validator
|
118
|
+
|
119
|
+
->date('birthday')
|
120
|
+
|
121
|
+
->allowEmpty('birthday');
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
$validator
|
126
|
+
|
127
|
+
->integer('country')
|
128
|
+
|
129
|
+
->allowEmpty('country');
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
$validator
|
134
|
+
|
135
|
+
->integer('prefecture')
|
136
|
+
|
137
|
+
->allowEmpty('prefecture');
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
$validator
|
142
|
+
|
143
|
+
->integer('language')
|
144
|
+
|
145
|
+
->allowEmpty('language');
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
$validator
|
150
|
+
|
151
|
+
->allowEmpty('created_by');
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
$validator
|
156
|
+
|
157
|
+
->dateTime('created_at');
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
$validator
|
162
|
+
|
163
|
+
->allowEmpty('updated_by');
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
$validator
|
168
|
+
|
169
|
+
->dateTime('updated_at');
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
return $validator;
|
30
174
|
|
31
175
|
}
|
32
176
|
|
33
|
-
```
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
$
|
68
|
-
|
69
|
-
->
|
70
|
-
|
71
|
-
->ad
|
72
|
-
|
73
|
-
'n
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
]
|
84
|
-
|
85
|
-
]);
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
$
|
90
|
-
|
91
|
-
->inte
|
92
|
-
|
93
|
-
->
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
$validator
|
106
|
-
|
107
|
-
->integer('country')
|
108
|
-
|
109
|
-
->allowEmpty('country');
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
$validator
|
114
|
-
|
115
|
-
->integer('prefecture')
|
116
|
-
|
117
|
-
->allowEmpty('prefecture');
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
$validator
|
122
|
-
|
123
|
-
->integer('language')
|
124
|
-
|
125
|
-
->allowEmpty('language');
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
$validator
|
130
|
-
|
131
|
-
->allowEmpty('created_by');
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
$validator
|
136
|
-
|
137
|
-
->dateTime('created_at');
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
$validator
|
142
|
-
|
143
|
-
->allowEmpty('updated_by');
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
$validator
|
148
|
-
|
149
|
-
->dateTime('updated_at');
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
return $validator;
|
154
|
-
|
155
|
-
}
|
177
|
+
```
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
Template
|
182
|
+
|
183
|
+
```
|
184
|
+
|
185
|
+
<div class="member form large-9 medium-8 columns content">
|
186
|
+
|
187
|
+
<?= $this->Form->create('member') ?>
|
188
|
+
|
189
|
+
<fieldset>
|
190
|
+
|
191
|
+
<legend><?= __('新規会員登録') ?></legend>
|
192
|
+
|
193
|
+
<p>全項目入力して下さい</p>
|
194
|
+
|
195
|
+
<?php
|
196
|
+
|
197
|
+
// if (isset($ValidationError) && is_array($ValidationError)){
|
198
|
+
|
199
|
+
// foreach ($ValidationError as $key => $values){
|
200
|
+
|
201
|
+
// foreach ($values as $value){
|
202
|
+
|
203
|
+
// echo '<p class="error">' . $value . '</p>';
|
204
|
+
|
205
|
+
// }
|
206
|
+
|
207
|
+
// }
|
208
|
+
|
209
|
+
// }
|
210
|
+
|
211
|
+
echo $this->Form->input('member_detail.0.nickname', ['label' => __('なまえ')]);
|
212
|
+
|
213
|
+
echo $this->Form->input('member_detail.0.gender', ['label' => __('性別'), 'type' => 'radio', 'options' => $Genders]);
|
214
|
+
|
215
|
+
echo $this->Form->input('member_detail.0.birthday', ['label' => __('生年月日'), 'type' => 'date', 'dateFormat' => 'YMD', 'monthNames' => false, 'maxYear' => date('Y'), 'minYear' => 1850, 'empty' => '---']);
|
216
|
+
|
217
|
+
echo $this->Form->input('member_detail.0.country', ['label' => __('国籍'), 'type' => 'select', 'options' => $Countries]);
|
218
|
+
|
219
|
+
if ($Prefectures) {
|
220
|
+
|
221
|
+
echo $this->Form->input('member_detail.0.prefecture',
|
222
|
+
|
223
|
+
['label' => __('都道府県'), 'type' => 'select', 'options' => $Prefectures]);
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
echo $this->Form->input('member_detail.0.language', ['label' => __('言語'), 'type' => 'select', 'options' => $Languages]);
|
228
|
+
|
229
|
+
echo $this->Form->input('mail_address', ['label' => __('メールアドレス'), 'type' => 'email']);
|
230
|
+
|
231
|
+
echo $this->Form->input('login_id', ['label' => __('ログインID'), 'type' => 'text']);
|
232
|
+
|
233
|
+
echo $this->Form->input('login_password', ['label' => __('パスワード'), 'type' => 'password']);
|
234
|
+
|
235
|
+
echo $this->Form->hidden('is_active', ['default' => 1]);
|
236
|
+
|
237
|
+
echo $this->Form->hidden('is_deleted', ['default' => 0]);
|
238
|
+
|
239
|
+
?>
|
240
|
+
|
241
|
+
</fieldset>
|
242
|
+
|
243
|
+
<?= $this->Form->button(__('確認')) ?>
|
244
|
+
|
245
|
+
<?= $this->Form->end() ?>
|
246
|
+
|
247
|
+
</div>
|
156
248
|
|
157
249
|
```
|
158
250
|
|
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,6 +50,114 @@
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
+
Table
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
public function validationDefault(Validator $validator)
|
58
|
+
|
59
|
+
{
|
60
|
+
|
61
|
+
$validator
|
62
|
+
|
63
|
+
->allowEmpty('id', 'create');
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
$validator
|
68
|
+
|
69
|
+
->allowEmpty('nickname')
|
70
|
+
|
71
|
+
->add('nickname', [
|
72
|
+
|
73
|
+
'ngword' => [
|
74
|
+
|
75
|
+
'rule' => function($value, $context){
|
76
|
+
|
77
|
+
return !TableRegistry::get('ng_word')->exists(["'{$value}' LIKE concat('%', word, '%')"]);
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
'massage' => '「おなまえ」に不適切な語句が含まれています'
|
82
|
+
|
83
|
+
]
|
84
|
+
|
85
|
+
]);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
$validator
|
90
|
+
|
91
|
+
->integer('gender')
|
92
|
+
|
93
|
+
->notEmpty('gender');
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
$validator
|
98
|
+
|
99
|
+
->date('birthday')
|
100
|
+
|
101
|
+
->allowEmpty('birthday');
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
$validator
|
106
|
+
|
107
|
+
->integer('country')
|
108
|
+
|
109
|
+
->allowEmpty('country');
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
$validator
|
114
|
+
|
115
|
+
->integer('prefecture')
|
116
|
+
|
117
|
+
->allowEmpty('prefecture');
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
$validator
|
122
|
+
|
123
|
+
->integer('language')
|
124
|
+
|
125
|
+
->allowEmpty('language');
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
$validator
|
130
|
+
|
131
|
+
->allowEmpty('created_by');
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
$validator
|
136
|
+
|
137
|
+
->dateTime('created_at');
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
$validator
|
142
|
+
|
143
|
+
->allowEmpty('updated_by');
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
$validator
|
148
|
+
|
149
|
+
->dateTime('updated_at');
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
return $validator;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
|
160
|
+
|
53
161
|
ここからどうして良いか分かりません。
|
54
162
|
|
55
163
|
|
2
本文修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,15 @@
|
|
36
36
|
|
37
37
|
```
|
38
38
|
|
39
|
+
$ngWords = $this->ngwords->find();
|
40
|
+
|
41
|
+
foreach ($ngWords as $row){
|
42
|
+
|
43
|
+
$word[] = $row->word;
|
44
|
+
|
45
|
+
}
|
46
|
+
|
39
|
-
$this->set('ngwords', $
|
47
|
+
$this->set('ngwords', $word);
|
40
48
|
|
41
49
|
```
|
42
50
|
|
1
本文追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,6 +46,10 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
+
カスタムバリデーションの作成や取得したデータをそこに反映させる方法等・・
|
50
|
+
|
51
|
+
|
52
|
+
|
49
53
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
50
54
|
|
51
55
|
php7.1.1 / cake PHP3.3.12/
|