mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 22:34:24 +00:00
adapt select moderator field in new event form
This commit is contained in:
parent
fda14a52e0
commit
aa02597541
@ -1,5 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Chill\EventBundle\Controller;
|
namespace Chill\EventBundle\Controller;
|
||||||
|
|
||||||
use Chill\EventBundle\Entity\Participation;
|
use Chill\EventBundle\Entity\Participation;
|
||||||
@ -105,7 +125,9 @@ class EventController extends Controller
|
|||||||
{
|
{
|
||||||
$form = $this->createForm(EventType::class, $entity, array(
|
$form = $this->createForm(EventType::class, $entity, array(
|
||||||
'action' => $this->generateUrl('chill_event__event_create'),
|
'action' => $this->generateUrl('chill_event__event_create'),
|
||||||
'method' => 'POST'
|
'method' => 'POST',
|
||||||
|
'center' => $entity->getCenter(),
|
||||||
|
'role' => new Role('CHILL_EVENT_CREATE')
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||||
|
@ -1,21 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Chill\EventBundle\Form;
|
namespace Chill\EventBundle\Form;
|
||||||
|
|
||||||
use Chill\MainBundle\Form\Type\ChillDateTimeType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
|
||||||
use Chill\EventBundle\Form\Type\PickEventType;
|
use Chill\EventBundle\Form\Type\PickEventType;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateTimeType;
|
||||||
|
use Chill\MainBundle\Form\Type\UserPickerType;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
|
||||||
class EventType extends AbstractType
|
class EventType extends AbstractType
|
||||||
@ -76,6 +97,7 @@ class EventType extends AbstractType
|
|||||||
'class' => Center::class,
|
'class' => Center::class,
|
||||||
'choices' => $userReachableCenters,
|
'choices' => $userReachableCenters,
|
||||||
'attr' => array('class' => 'select2 chill-category-link-parent'),
|
'attr' => array('class' => 'select2 chill-category-link-parent'),
|
||||||
|
'disabled' => true,
|
||||||
'choice_attr' => function (Center $center) {
|
'choice_attr' => function (Center $center) {
|
||||||
return array(
|
return array(
|
||||||
'class' => ' chill-category-link-parent',
|
'class' => ' chill-category-link-parent',
|
||||||
@ -103,22 +125,26 @@ class EventType extends AbstractType
|
|||||||
},
|
},
|
||||||
))
|
))
|
||||||
->add('type', PickEventType::class)
|
->add('type', PickEventType::class)
|
||||||
->add('moderator', EntityType::class, array(
|
->add('moderator', UserPickerType::class, array(
|
||||||
'class' => User::class,
|
'center' => $options['center'],
|
||||||
'required' => false,
|
'role' => $options['role']
|
||||||
'placeholder' => ''
|
|
||||||
))
|
))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param OptionsResolverInterface $resolver
|
* @param OptionsResolver $resolver
|
||||||
*/
|
*/
|
||||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'Chill\EventBundle\Entity\Event'
|
'data_class' => 'Chill\EventBundle\Entity\Event'
|
||||||
));
|
));
|
||||||
|
$resolver
|
||||||
|
->setRequired(array('center', 'role'))
|
||||||
|
->setAllowedTypes('center', Center::class)
|
||||||
|
->setAllowedTypes('role', Role::class)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user