<?php
namespace App\Form\Filtro;
use App\Entity\Filtro\FiltroFichaje;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
class FiltroFichajeProyectoTareaType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options): void {
$builder
->add('tarea', EntityType::class, [
'class' => \App\Entity\Comun\Tarea::class,
'query_builder' => function (\App\Repository\Comun\TareaRepository $er) use ($options) {
return $er->createQueryBuilder('t')
->where('t.proyecto = :proyecto')
->setParameter('proyecto', $options['proyecto'])
->orderBy('t.nombre', 'DESC');
},
'label' => 'fichaje.tarea',
'attr' => ['class' => 'form-control'],
'required' => false,
'attr' => [
'class' => 'form-control select2',
'placeholder' => 'fichaje.placeholderTarea',
'style' => 'width:100%',
'data-toggle' => "select2"
]
]) ;
}
public function configureOptions(OptionsResolver $resolver): void {
$resolver->setDefaults([
'data_class' => null,
'proyecto'=>null,
]);
}
}