mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4744014cf2
@ -29,6 +29,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface
|
||||
$loader->load('repositories.yml');
|
||||
$loader->load('search.yml');
|
||||
$loader->load('authorization.yml');
|
||||
$loader->load('forms.yml');
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
|
@ -5,6 +5,7 @@ namespace Chill\EventBundle\Form;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
use Chill\EventBundle\Form\Type\TranslatableEventType;
|
||||
|
||||
class EventType extends AbstractType
|
||||
{
|
||||
@ -16,10 +17,18 @@ class EventType extends AbstractType
|
||||
{
|
||||
$builder
|
||||
->add('label')
|
||||
->add('date')
|
||||
->add(
|
||||
'date',
|
||||
'date',
|
||||
array(
|
||||
'required' => true,
|
||||
'widget' => 'single_text',
|
||||
'format' => 'dd-MM-yyyy'
|
||||
)
|
||||
)
|
||||
->add('center')
|
||||
->add('type')
|
||||
->add('circle')
|
||||
->add('type', TranslatableEventType::class)
|
||||
//->add('circle')
|
||||
;
|
||||
}
|
||||
|
||||
|
70
Form/Type/TranslatableEventType.php
Normal file
70
Form/Type/TranslatableEventType.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2016, 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\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Chill\EventBundle\Entity\EventType;
|
||||
|
||||
/**
|
||||
* Description of TranslatableEventType
|
||||
*
|
||||
* @author Champs-Libres Coop
|
||||
*/
|
||||
class TranslatableEventType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
protected $translatableStringHelper;
|
||||
|
||||
public function __construct(TranslatableStringHelper $helper)
|
||||
{
|
||||
$this->translatableStringHelper = $helper;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$helper = $this->translatableStringHelper;
|
||||
$resolver->setDefaults(
|
||||
array(
|
||||
'class' => EventType::class,
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('et')
|
||||
->where('et.active = true');
|
||||
},
|
||||
'choice_label' => function (EventType $t) use ($helper) {
|
||||
return $helper->localize($t->getLabel());
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
chill_event_event:
|
||||
resource: "@ChillEventBundle/Resources/config/routing/event.yml"
|
||||
prefix: /event
|
||||
prefix: /{_locale}/event/event
|
||||
|
||||
chill_event_fr_admin_event_status:
|
||||
resource: "@ChillEventBundle/Resources/config/routing/status.yml"
|
||||
@ -13,4 +13,3 @@ chill_event_admin_role:
|
||||
chill_event_admin_event_type:
|
||||
resource: "@ChillEventBundle/Resources/config/routing/eventtype.yml"
|
||||
prefix: /{_locale}/admin/event/event_type
|
||||
|
||||
|
7
Resources/config/services/forms.yml
Normal file
7
Resources/config/services/forms.yml
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
chill_event.form.event_type_type:
|
||||
class: Chill\EventBundle\Form\Type\TranslatableEventType
|
||||
arguments:
|
||||
- "@chill.main.helper.translatable_string"
|
||||
tags:
|
||||
- { name: form.type }
|
@ -1,6 +1,6 @@
|
||||
{% extends '::base.html.twig' %}
|
||||
{% extends 'ChillEventBundle::layout.html.twig' %}
|
||||
|
||||
{% block body -%}
|
||||
{% block event_content -%}
|
||||
<h1>Event creation</h1>
|
||||
|
||||
{{ form(form) }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user