Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Crud many-to-many save issue - edit method + request data
/**
* Method: edit
*
* Amend user entity before save
*
* {@inheritDoc}
*/
public function edit($id)
{
if ($this->request->is('put')) {
debug($this->request->getData());
die;
}
// set dirty password false when empty
$this->Crud->on('beforeSave', function (Event $event) {
if (empty($event->getSubject()->entity->password)) {
$event->getSubject()->entity->setDirty('password', false);
}
});
return $this->Crud->execute();
}
// Request data debug
[
'email' => 'okon.curtis@botsford.biz',
'first_name' => 'Vladimir',
'last_name' => 'Rowe',
'roles' => [
'_ids' => [
(int) 0 => '2',
(int) 1 => '1',
(int) 2 => '3',
(int) 3 => '6'
]
],
'tags' => '',
'status' => '1',
'password' => ''
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.