feat: selectable country for custom destinations
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Form;
|
|||||||
use App\BusProNet\DataProvider\HotelDataProvider;
|
use App\BusProNet\DataProvider\HotelDataProvider;
|
||||||
use App\Model\DestinationDto;
|
use App\Model\DestinationDto;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@@ -37,6 +38,16 @@ class DestinationType extends AbstractType
|
|||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
'allow_delete' => true,
|
'allow_delete' => true,
|
||||||
])
|
])
|
||||||
|
->add('country', ChoiceType::class, [
|
||||||
|
'label' => 'Land',
|
||||||
|
'choices' => [
|
||||||
|
'Österreich' => 'a',
|
||||||
|
'Schweiz' => 'ch',
|
||||||
|
'Frankreich' => 'f',
|
||||||
|
'Italien' => 'i',
|
||||||
|
'Deutschland' => 'd',
|
||||||
|
],
|
||||||
|
])
|
||||||
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
|
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
|
||||||
$form = $event->getForm();
|
$form = $event->getForm();
|
||||||
$data = $event->getData();
|
$data = $event->getData();
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ class DestinationDto
|
|||||||
#[Assert\NotBlank(message: 'Bitte angeben')]
|
#[Assert\NotBlank(message: 'Bitte angeben')]
|
||||||
private ?string $product = null;
|
private ?string $product = null;
|
||||||
|
|
||||||
|
#[Assert\Choice(choices: ['a', 'ch', 'd', 'f', 'i'], message: 'Ungültige Auswahl')]
|
||||||
|
private ?string $country = null;
|
||||||
|
|
||||||
#[Assert\NotNull(message: 'Bitte das Beginndatum angeben')]
|
#[Assert\NotNull(message: 'Bitte das Beginndatum angeben')]
|
||||||
private ?\DateTimeImmutable $dateFrom = null;
|
private ?\DateTimeImmutable $dateFrom = null;
|
||||||
|
|
||||||
@@ -52,6 +55,18 @@ class DestinationDto
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCountry(): ?string
|
||||||
|
{
|
||||||
|
return $this->country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCountry(?string $country): static
|
||||||
|
{
|
||||||
|
$this->country = $country;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDateFrom(): ?\DateTimeImmutable
|
public function getDateFrom(): ?\DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->dateFrom;
|
return $this->dateFrom;
|
||||||
|
|||||||
@@ -12,24 +12,31 @@
|
|||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
<div class="flex flex-col space-y-4 pb-8">
|
<div class="flex flex-col space-y-4 pb-8">
|
||||||
{{ form_row(form.product) }}
|
<div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">
|
||||||
{{ form_row(form.dateFrom) }}
|
{{ form_row(form.product) }}
|
||||||
{{ form_row(form.dateTo) }}
|
{{ form_row(form.hotelBusProId) }}
|
||||||
{{ form_row(form.hotelBusProId) }}
|
</div>
|
||||||
<div {{ stimulus_controller('form-collection', { 'prototype': _self.collectionRow(form.pickups.vars.prototype)|json_encode }) }}>
|
<div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">
|
||||||
<h4 class="font-bold pb-2">
|
{{ form_row(form.dateFrom) }}
|
||||||
Buszustiege
|
{{ form_row(form.dateTo) }}
|
||||||
</h4>
|
</div>
|
||||||
<div {{ stimulus_target('form-collection', 'fields')}} class="flex flex-col space-y-4 mb-4">
|
<div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">
|
||||||
{% do form.pickups.setRendered %}
|
{{ form_row(form.country) }}
|
||||||
{%- for pickup in form.pickups -%}{{- _self.collectionRow(pickup) -}}{%- endfor -%}
|
<div {{ stimulus_controller('form-collection', { 'prototype': _self.collectionRow(form.pickups.vars.prototype)|json_encode }) }}>
|
||||||
</div>
|
<h4 class="font-bold pb-2">
|
||||||
<div class="flex justify-end">
|
Buszustiege
|
||||||
<button type="button"
|
</h4>
|
||||||
{{ stimulus_action('form-collection', 'addItem') }}
|
<div {{ stimulus_target('form-collection', 'fields')}} class="flex flex-col space-y-4 mb-4">
|
||||||
title="Zustieg hinzufügen">
|
{% do form.pickups.setRendered %}
|
||||||
{{ icon('plus', 'w-4 h-4 pointer-events-none') }}
|
{%- for pickup in form.pickups -%}{{- _self.collectionRow(pickup) -}}{%- endfor -%}
|
||||||
</button>
|
</div>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<button type="button"
|
||||||
|
{{ stimulus_action('form-collection', 'addItem') }}
|
||||||
|
title="Zustieg hinzufügen">
|
||||||
|
{{ icon('plus', 'w-4 h-4 pointer-events-none') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user