public function editAction(Request $request) { $id = $request->get('id'); $em = $this->getDoctrine()->getManager(); $inform = $em->getRepository('AcmeInfoBundle:Info')->find($id); $info = new \Acme\InfoBundle\Entity\Info(); $info->setTitle($inform->getTitle()); $info->setDescription($inform->getDescription()); $form = $this->createFormBuilder($info)->add('title', 'text')->add('description', 'textarea')->getForm(); $form->handleRequest($request); $validator = $this->get('validator'); $errors = $validator->validate($info); if (count($errors) > 0) { //echo "invalid"; } else { if ($request->isMethod('post') == 'edit') { $a = $request->request->get('form'); $info = $em->getRepository('AcmeInfoBundle:Info')->find($id); $info->setTitle($a['title']); $info->setDescription($a['description']); $em->persist($info); $em->flush(); return $this->redirect($this->generateUrl('acme_info')); } } return $this->render('AcmeInfoBundle:Default:edit.html.twig', array('form' => $form->createView(), 'id' => $id)); }
public function editAction(Request $request) { $a = 0; $b = 100; $c = array(); for ($a; $a <= $b; $a++) { $c[] = $a; } $id = $request->get('id'); $em = $this->getDoctrine()->getManager(); $inform = $em->getRepository('AcmeInfoBundle:Info')->find($id); $info = new \Acme\InfoBundle\Entity\Info(); $info->setTitle($inform->getTitle()); $info->setPercentage($inform->getPercentage()); $form = $this->createFormBuilder($info)->add('title', 'text')->add('percentage', 'choice', array('choices' => array('placeholder' => 'select percentage', '' => $c)))->getForm(); $form->handleRequest($request); $validator = $this->get('validator'); $errors = $validator->validate($info); if (count($errors) > 0) { //echo "invalid"; } else { if ($request->isMethod('post') == 'edit') { $a = $request->request->get('form'); $info = $em->getRepository('AcmeInfoBundle:Info')->find($id); $info->setTitle($a['title']); $info->setPercentage($a['percentage']); $em->persist($info); $em->flush(); $this->get('session')->getFlashBag()->set('success', 'Info Update Successfully'); return $this->redirect($this->generateUrl('acme_info')); } } return $this->render('AcmeInfoBundle:Default:edit.html.twig', array('form' => $form->createView(), 'id' => $id)); }
/** * {@inheritDoc} */ public function getUpdatedAt() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUpdatedAt', array()); return parent::getUpdatedAt(); }