質問編集履歴
2
問題箇所の出力結果の追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -213,6 +213,52 @@
|
|
213
213
|
|
214
214
|
みなさんのお知恵をお貸しください。よろしくお願いいたします。
|
215
215
|
|
216
|
+
|
217
|
+
### 問題あると思われるpatchEntityの前後の出力結果
|
218
|
+
Controller/Admin/UsersController
|
219
|
+
```
|
220
|
+
public function add()
|
221
|
+
{
|
222
|
+
$user = $this->Users->newEntity();
|
223
|
+
if ($this->request->is('post')) {
|
224
|
+
Debugger::dump($this->request->data);
|
225
|
+
$user = $this->Users->patchEntity($user, $this->request->data);
|
226
|
+
Debugger::dump($user);
|
227
|
+
exit;
|
228
|
+
=====上に同じなので、省略====
|
229
|
+
}
|
230
|
+
```
|
231
|
+
```
|
232
|
+
[
|
233
|
+
'name' => 'yamada',
|
234
|
+
'password' => 'ymymym',
|
235
|
+
'role' => 'admin'
|
236
|
+
// セレクトボックスでちゃんとRolesの値が表示できていて、選択肢のうち、adminを選択して送信。
|
237
|
+
// postで送信された値はadminなのでここまでは想定通り。
|
238
|
+
]
|
239
|
+
object(App\Model\Entity\User) {
|
240
|
+
|
241
|
+
'name' => 'yamada',
|
242
|
+
'password' => 'ymymym',
|
243
|
+
'role' => null, // nullに変換される!!!!!
|
244
|
+
'[new]' => true,
|
245
|
+
'[accessible]' => [
|
246
|
+
'*' => true
|
247
|
+
],
|
248
|
+
'[dirty]' => [
|
249
|
+
'name' => true,
|
250
|
+
'password' => true,
|
251
|
+
'role' => true
|
252
|
+
],
|
253
|
+
'[original]' => [],
|
254
|
+
'[virtual]' => [],
|
255
|
+
'[errors]' => [],
|
256
|
+
'[repository]' => 'Users'
|
257
|
+
|
258
|
+
}
|
259
|
+
```
|
260
|
+
|
261
|
+
|
216
262
|
### 補足情報(FW/ツールのバージョンなど)
|
217
263
|
|
218
264
|
CakePHP3.1.14
|
1
Controller/Admin/UsersControllerの記入漏れ
title
CHANGED
File without changes
|
body
CHANGED
@@ -138,8 +138,10 @@
|
|
138
138
|
use Cake\ORM\TableRegistry;
|
139
139
|
use Cake\Error\Debugger;
|
140
140
|
|
141
|
+
class UsersController extends AppController
|
142
|
+
{
|
141
143
|
|
142
|
-
public function add()
|
144
|
+
public function add()
|
143
145
|
{
|
144
146
|
$user = $this->Users->newEntity();
|
145
147
|
if ($this->request->is('post')) {
|
@@ -155,6 +157,8 @@
|
|
155
157
|
$this->set(compact('user', 'roles'));
|
156
158
|
$this->set('_serialize', ['user']);
|
157
159
|
}
|
160
|
+
|
161
|
+
}
|
158
162
|
```
|
159
163
|
|
160
164
|
Template/Admin/Users/add.ctp
|