Created
November 23, 2011 04:38
Revisions
-
leevigraham revised this gist
Nov 23, 2011 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <form action="{{ path('put_activity', {'id': activity.object.id }) }}" method="post" {{ form_enctype(activity.edit_activity_form) }} > <input type="hidden" name="_method" value="PUT" /> <input type="hidden" name="_target_path" value="get_activities" /> {{ form_errors(activity.edit_activity_form) }} {{ form_widget(activity.edit_activity_form._token) }} <div class="ft ft-textarea ft-description"> <label> {{ form_label(create_activity_form.description) }} </label> {{ form_widget(create_activity_form.description) }} </div> <div class="actions"> <button type="submit">Edit Activity</button> </div> </form> -
leevigraham created this gist
Nov 23, 2011 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ <?php namespace Newism\ActivityBundle\Form; use Symfony\Component\Form\AbstractType, Symfony\Component\Form\FormBuilder, Symfony\Component\Form\FormEvents, Symfony\Component\Form\Event\DataEvent; use Newism\ProjectBundle\Form\EventListener\AddTaskFieldSubscriber; class ActivityType extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $builder ->add('description') ->add('duration') ->add('timerStartedAt') ->add('startedAt') ->add('user') ; } public function getName() { return 'newism_activitybundle_activitytype'; } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ <?php /** * Updates an existing Activity entity. * @Route("/activity/{id}", name="put_activity") * @Method("put") */ public function putActivityAction($id) { $em = $this->getDoctrine()->getEntityManager(); $activity = $em->getRepository('Newism\ActivityBundle\Entity\Activity')->find($id); if (!$activity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } $activity = $em->getRepository('Newism\ActivityBundle\Entity\Activity')->find($id); $editForm = $this->createForm(new ActivityType(), $activity); $request = $this->getRequest(); $editForm->bindRequest($request); if ($editForm->isValid()) { $em->persist($activity); $em->flush(); } if(!$target_path = $this->getRequest()->request->get('_target_path')) { $target_path = "get_activities"; } return $this->redirect($this->generateUrl($target_path, array('id' => $activity->getId()))); }