Skip to content

Instantly share code, notes, and snippets.

@lorenzo
Last active October 20, 2015 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzo/4b84555b6953e2b329db to your computer and use it in GitHub Desktop.
Save lorenzo/4b84555b6953e2b329db to your computer and use it in GitHub Desktop.
Table
public function validationDefault(Validator $validator)
{
$validator
->requirePresence('device_id', 'create')
->notEmpty('device_id');
return $validator;
}
Controller
public function custom()
{
$tag = $this->Tags->newEntity();
if ($this->request->is('post')) {
$tag = $this->Tags->patchEntity($tag, $this->request->data);
if (!$tag->errors()) {
$post = $this->Tags->Posts->get($tag->post_id);
$tag->number = $post->number;
$this->Tags->save($tag);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment