WIP: Implement application process

This commit is contained in:
Björn Fromme committed 2023-10-09 16:59:35 +02:00
1 parent abced8c924
commit 3a458df94f
17 files changed
+441 -219

No files matched your search

+39 -29
View File
@@ -5,6 +5,7 @@ namespace App\Form;
use App\Entity\Application;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
@@ -15,36 +16,45 @@ class TeamerApplicationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
/** @var Application $application */
$application = $event->getData();
if (null === $application) {
return;
}
$assignment = $application->getAssignment();
if (null === $assignment->getPickup()) {
return;
}
$teamer = $application->getTeamer();
if (in_array($assignment->getPickup(), $teamer->getPickups())) {
return;
}
$event->getForm()->add('confirmPickup', CheckboxType::class, [
'label' => 'Ich bestätige den abweichenden Buszustieg',
'mapped' => false,
'constraints' => [
new IsTrue([
'message' => 'Deine Bestätigung ist erforderlich',
]),
$builder
->add('requests', TextareaType::class, [
'label' => 'Wünsche',
'required' => false,
'attr' => [
'rows' => 3,
],
]);
});
])
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
/** @var Application $application */
$application = $event->getData();
if (null === $application) {
return;
}
$assignment = $application->getAssignment();
if (null === $assignment->getPickup()) {
return;
}
$teamer = $application->getTeamer();
if (in_array($assignment->getPickup(), $teamer->getPickups())) {
return;
}
$event->getForm()->add('confirmPickup', CheckboxType::class, [
'label' => 'Ich bestätige den abweichenden Buszustieg',
'mapped' => false,
'constraints' => [
new IsTrue([
'message' => 'Deine Bestätigung ist erforderlich',
]),
],
]);
})
;
}
public function configureOptions(OptionsResolver $resolver): void