/** * @return Form */ public function create() { $form = new ObjectForm(); $form->injectObjectMapper($this->objectMapper); if ($this->translator) { $form->setTranslator($this->translator); } return $form; }
public function editAction($id) { $object = $this->getObjectById($id); $form = new ObjectForm(null, Security::getCurrentUser()); if ($object) { $content = $this->decryptContent($object); $form->setBody($content); $form->setEntity($object); $this->view->setVar('object', $object); } $this->view->setVar('form', $form); if ($this->request->isPost() && $form->isValid($_POST)) { if (!$this->security->checkToken()) { $this->flash->error('Invalid security token. Please try submitting the form again.'); return; } $savedObject = $form->handleSubmit(); $this->response->redirect(self::getObjectUrl($savedObject)); } }