protected function create() { $params = $this->getAllowedKeysForCreate(); $note = new Note(); $note->fromArray($params); $category = $_POST['category']; $category = CategoryQuery::create()->filterByUser($this->params['user'])->filterByName($category)->findOne(); if ($category != null) { $note->setCategory($category); } $note->setUser($this->params['user']); $note->save(); $this->addFlash("success", "Note added"); redirectTo($note->getShowPath()); }