Last active
August 29, 2015 14:18
-
-
Save converge/4a5637be6772a4c9a06f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# ClientsController | |
# | |
# I have this Client table, and User table, need to create a user(login/password) when creating a client | |
# | |
public function add() { | |
$client = $this->Clients->newEntity(); | |
if ($this->request->is('post')) { | |
$client = $this->Clients->patchEntity($client, $this->request->data); | |
$client = [ | |
'user' => [ | |
'username' => 'teste', | |
'password' => 'teste' | |
] | |
]; | |
if ($this->Clients->save($client)) { | |
$this->Flash->success('The client has been saved.'); | |
return $this->redirect(['action' => 'index']); | |
} else { | |
$this->Flash->error('The client could not be saved. Please, try again.'); | |
} | |
} | |
$regions = $this->getRegions(); | |
$this->set(compact('client', 'regions')); | |
$this->set('_serialize', ['client']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try