I have a user model with an email and password. I added the fields first_name and last_name to my database and the form for the add view like this:
9 <div class="users form large-12 medium-9 columns">
10 <?= $this->Form->create($user) ?>
11 <fieldset>
12 <legend><?= __('New Account') ?></legend>
13 <?php
14 echo $this->Form->input('email');
15 echo $this->Form->input('first_name');
16 echo $this->Form->input('last_name');
17 echo $this->Form->input('password');
18
19 ?>
20 </fieldset>
21 <?= $this->Form->button(__('Submit')) ?>
22 <?= $this->Form->end() ?>
23 </div>
The email and password save without issue, but first_name and last_name never do. This is the controller function. Adding the commented line causes the first_name field to save, but it seems pretty clear that I shouldn't have to do that.
46 public function add()
47 {
48 $user = $this->Users->newEntity();
49 if ($this->request->is('post')) {
50 $user = $this->Users->patchEntity($user, $this->request->data);
51 //$user->first_name = $this->request->data['first_name'];
52 if ($this->Users->save($user)) {
53 $this->Flash->success(__('The user has been saved.'));
54 return $this->redirect(['action' => 'index']);
55 } else {
56 $this->Flash->error(__('The user could not be saved. Please, try again.'));
57 }
58 }
59 $books = $this->Users->Books->find('list', ['limit' => 200]);
60 $this->set(compact('user', 'books'));
61 $this->set('_serialize', ['user']);
62 }
Does anyone know why this is happening? I tried clearing the model cache but nothing changed.
Thanks!
debug
to1
or2
in yourcore.php
file withConfigure::write('debug', 2);
– HoltCakePHP 2.0
. – Holt