mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-24 08:33:49 +00:00
add a form to make a ling with 'add a participant' page
This commit is contained in:
@@ -4,9 +4,13 @@ namespace Chill\EventBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
use Chill\PersonBundle\Form\Type\PickPersonType;
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Chill\EventBundle\Form\EventType;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
/**
|
||||
* Event controller.
|
||||
@@ -103,11 +107,52 @@ class EventController extends Controller
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_EVENT_SEE_DETAILS', $entity,
|
||||
"You are not allowed to see details on this event");
|
||||
|
||||
$addParticipationByPersonForm = $this->createAddParticipationByPersonForm($entity);
|
||||
|
||||
return $this->render('ChillEventBundle:Event:show.html.twig', array(
|
||||
'event' => $entity
|
||||
'event' => $entity,
|
||||
'form_add_participation_by_person' => $addParticipationByPersonForm->createView()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* create a form to add a participation with a person
|
||||
*
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
protected function createAddParticipationByPersonForm(Event $event)
|
||||
{
|
||||
/* @var $builder \Symfony\Component\Form\FormBuilderInterface */
|
||||
$builder = $this
|
||||
->get('form.factory')
|
||||
->createNamedBuilder(
|
||||
null,
|
||||
FormType::class,
|
||||
null,
|
||||
array(
|
||||
'method' => 'GET',
|
||||
'action' => $this->generateUrl('chill_event_participation_new'),
|
||||
'csrf_protection' => false
|
||||
))
|
||||
;
|
||||
|
||||
$builder->add('person_id', PickPersonType::class, array(
|
||||
'role' => new Role('CHILL_EVENT_CREATE'),
|
||||
'centers' => $event->getCenter()
|
||||
));
|
||||
|
||||
$builder->add('center_id', HiddenType::class, array(
|
||||
'data' => $event->getCenter()->getId()
|
||||
));
|
||||
|
||||
$builder->add('submit', SubmitType::class,
|
||||
array(
|
||||
'label' => 'Add a participation'
|
||||
));
|
||||
|
||||
return $builder->getForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing Event entity.
|
||||
|
Reference in New Issue
Block a user