diff --git a/Form/Type/CommentType.php b/Form/Type/CommentType.php index fe14290f3..a088af573 100644 --- a/Form/Type/CommentType.php +++ b/Form/Type/CommentType.php @@ -45,7 +45,7 @@ class CommentType extends AbstractType { $builder ->add('comment', TextareaType::class, [ - 'label' => false, + ]) ; diff --git a/Templating/Entity/CommentRender.php b/Templating/Entity/CommentRender.php index 6291f3d47..d5fce5749 100644 --- a/Templating/Entity/CommentRender.php +++ b/Templating/Entity/CommentRender.php @@ -25,7 +25,6 @@ use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender; - class CommentRender extends AbstractChillEntityRender { /** @@ -48,24 +47,28 @@ class CommentRender extends AbstractChillEntityRender { $username = ''; - $user = $this->userRepository->find($entity->getUserId()); - if ($user instanceof User) { - $username = $user->getUsername(); + if ($entity->getUserId()) { + $user = $this->userRepository->find($entity->getUserId()); + if ($user instanceof User) { + $username = $user->getUsername(); + } } $str = $this->getDefaultOpeningBox('comment-embeddable'). ''. nl2br($entity->getComment()). - ''. - ''. - $entity->getDate()->format('d/m/Y h:i'); ''; + if ($entity->getDate() instanceof \DateTime) { + $str .= ''. + $entity->getDate()->format('d/m/Y H:i'); + ''; + } + if (strlen($username) > 0) { $str .= ''. $username. - '' - ; + ''; } $str .= $this->getDefaultClosingBox();