diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 6c7e9e503..b1a6f8850 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -31,6 +31,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; use LogicException; use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Range; @@ -113,6 +114,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable", nullable=false) * @Serializer\Groups({"calendar:read", "read"}) + * @Assert\NotNull(message="calendar.An end date is required") */ private ?DateTimeImmutable $endDate = null; @@ -139,12 +141,14 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") * @Serializer\Groups({"read"}) + * @Assert\NotNull(message="calendar.A location is required") */ private ?Location $location = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @Serializer\Groups({"calendar:read", "read"}) + * @Assert\NotNull(message="calendar.A main user is mandatory") */ private ?User $mainUser = null; @@ -152,6 +156,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") * @ORM\JoinTable(name="chill_calendar.calendar_to_persons") * @Serializer\Groups({"calendar:read", "read"}) + * @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.") */ private Collection $persons; @@ -181,6 +186,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable", nullable=false) * @Serializer\Groups({"calendar:read", "read"}) + * @Assert\NotNull(message="calendar.A start date is required") */ private ?DateTimeImmutable $startDate = null; diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index ebd62fb2e..1a38c1ba6 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -101,7 +101,7 @@ class CalendarType extends AbstractType return $res; }, static function (?string $dateAsString): ?DateTimeImmutable { - if ('' === $dateAsString) { + if ('' === $dateAsString || null === $dateAsString) { return null; } @@ -122,7 +122,7 @@ class CalendarType extends AbstractType return $res; }, static function (?string $dateAsString): ?DateTimeImmutable { - if ('' === $dateAsString) { + if ('' === $dateAsString || null === $dateAsString) { return null; } diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig index 1407f5855..e71c3f7d4 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig @@ -82,14 +82,17 @@ } %} - {% if calendar.comment.comment is not empty %} -
- {{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} -
- {% endif %} {% endif %} + {% if calendar.comment.comment is not empty %} +
+
+ {{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} +
+
+ {% endif %} + {% if calendar.location is not empty %}
diff --git a/src/Bundle/ChillCalendarBundle/translations/validators.fr.yml b/src/Bundle/ChillCalendarBundle/translations/validators.fr.yml new file mode 100644 index 000000000..7d9be7a91 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/translations/validators.fr.yml @@ -0,0 +1,7 @@ +calendar: + At least {{ limit }} person is required.: Au moins {{ limit }} personne doit être associée à ce rendez-vous + An end date is required: Indiquez une date et heure de fin + A start date is required: Indiquez une date et heure de début + A location is required: Indiquez un lieu + A main user is mandator: Indiquez un utilisateur principal +