mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
form type created to handle selection of asideactivity categories, not yet operational
This commit is contained in:
parent
7a56ff7d29
commit
72b43e9a99
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\AsideActivityBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* Description of TranslatableAsideActivityCategory
|
||||
*
|
||||
* @author Champs-Libres Coop
|
||||
*/
|
||||
|
||||
|
||||
final class TranslatableAsideActivityCategory extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @var RequestStack
|
||||
*/
|
||||
private $requestStack;
|
||||
|
||||
public function __construct(RequestStack $requestStack)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'translatable_aside_activity_category';
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
||||
$resolver->setDefaults(
|
||||
array(
|
||||
'class' => 'ChillAsideActivityBundle:AsideActivityCategory',
|
||||
'choice_label' => 'name['.$locale.']',
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user