Integration code generated

This commit is contained in:
Marc Ducobu 2015-07-03 09:40:30 +02:00
parent 86b24f58ac
commit faffdee1ab
3 changed files with 16 additions and 8 deletions

View File

@ -68,7 +68,9 @@ class ActivityController extends Controller
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $entity->getId())));
return $this->redirect(
$this->generateUrl('chill_activity_activity_show',
array('id' => $entity->getId(), 'person_id' => $person_id)));
}
return $this->render('ChillActivityBundle:Activity:new.html.twig', array(
@ -107,6 +109,9 @@ class ActivityController extends Controller
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
$entity = new Activity();
$entity->setUser($this->get('security.context')->getToken()->getUser());
$entity->setDate(new \DateTime('now'));
$form = $this->createCreateForm($entity, $person);
return $this->render('ChillActivityBundle:Activity:new.html.twig', array(
@ -120,9 +125,10 @@ class ActivityController extends Controller
* Finds and displays a Activity entity.
*
*/
public function showAction($id)
public function showAction($person_id, $id)
{
$em = $this->getDoctrine()->getManager();
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
@ -130,7 +136,7 @@ class ActivityController extends Controller
throw $this->createNotFoundException('Unable to find Activity entity.');
}
$deleteForm = $this->createDeleteForm($id);
$deleteForm = $this->createDeleteForm($id, $person);
return $this->render('ChillActivityBundle:Activity:show.html.twig', array(
'entity' => $entity,
@ -243,10 +249,12 @@ class ActivityController extends Controller
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
private function createDeleteForm($id, $person)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('chill_activity_activity_delete', array('id' => $id)))
->setAction($this->generateUrl(
'chill_activity_activity_delete',
array('id' => $id, 'person_id' => $person->getId())))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()

View File

@ -99,7 +99,7 @@ class Activity
*
* @return Activity
*/
public function setUserr(User $user)
public function setUser(User $user)
{
$this->user = $user;

View File

@ -15,10 +15,10 @@ class ActivityType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('date')
->add('date', 'date', array('widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
->add('durationTime')
->add('remark')
->add('attendee')
->add('attendee', 'checkbox', array('required' => false))
->add('user')
//->add('scope')
//->add('reason')