diff --git a/src/Entity/Blog/Comment.php b/src/Entity/Blog/Comment.php index d9a0d92..edcbace 100644 --- a/src/Entity/Blog/Comment.php +++ b/src/Entity/Blog/Comment.php @@ -207,4 +207,17 @@ class Comment implements EntityInterface { return 'https://secure.gravatar.com/avatar/'.md5($this->getEmail()).'.jpg?s=90&d=retro'; } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf( + '[%s] (%s) %s', + $this->getAuthor(), + $this->getCreatedAt()->format('d/m/Y'), + substr($this->getContent(), 0, 20).'…' + ); + } } diff --git a/src/Form/Blog/CommentType.php b/src/Form/Blog/CommentType.php index 0c3b7ce..f729c67 100644 --- a/src/Form/Blog/CommentType.php +++ b/src/Form/Blog/CommentType.php @@ -106,7 +106,6 @@ class CommentType extends AbstractType [ 'label' => 'Réponse à', 'class' => Comment::class, - 'choice_label' => 'author', 'required' => false, 'multiple' => false, 'attr' => [ diff --git a/templates/blog/comment_admin/index.html.twig b/templates/blog/comment_admin/index.html.twig index 3003ff7..2a2d787 100644 --- a/templates/blog/comment_admin/index.html.twig +++ b/templates/blog/comment_admin/index.html.twig @@ -42,7 +42,14 @@ {{ item.author }} - Dans {{ item.post.title }} + Dans {{ item.post.title }} + + {% if item.parentComment %} + en réponse à + + {{ item.parentComment }} + + {% endif %}