protected function createComponentAddCommentForm() { $form = new AppForm(); $form->addTextArea("text", "Text", 40, 10); $form->addText("name", "Author", 40); $form->addText("mail", "E-mail", 40); $form->addSubmit("s", "Send comment"); $presenter = $this; $form->onSubmit[] = function ($form) use($presenter) { try { $values = $form->values; $values["page"] = $presenter->getParam("id"); $comment = Comment::create($values); $comment->save(); $presenter->flashMessage("Comment added!"); $presenter->redirect("this"); } catch (ModelException $e) { $comment->addErrorsToForm($form); } }; return $form; }