From b716f4a2a73e08a13687d110bdb1becd2e936bfb Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 9 Apr 2021 08:50:33 +0200 Subject: [PATCH] add notebook --- src/Entity/Blog/Post.php | 17 +++++++++++++++++ src/Form/Blog/CommentType.php | 1 + src/Form/Blog/PostType.php | 15 +++++++++++++++ templates/blog/post_admin/_form.html.twig | 12 ++++++++++++ templates/blog/post_admin/show.html.twig | 8 ++++++++ 5 files changed, 53 insertions(+) diff --git a/src/Entity/Blog/Post.php b/src/Entity/Blog/Post.php index dc4addf..703baba 100644 --- a/src/Entity/Blog/Post.php +++ b/src/Entity/Blog/Post.php @@ -112,6 +112,11 @@ class Post implements EntityInterface */ private $comments; + /** + * @ORM\Column(type="text", nullable=true) + */ + private $notebook; + public function __construct() { $this->categories = new ArrayCollection(); @@ -400,4 +405,16 @@ class Post implements EntityInterface return $this; } + + public function getNotebook(): ?string + { + return $this->notebook; + } + + public function setNotebook(?string $notebook): self + { + $this->notebook = $notebook; + + return $this; + } } diff --git a/src/Form/Blog/CommentType.php b/src/Form/Blog/CommentType.php index f729c67..f3452ff 100644 --- a/src/Form/Blog/CommentType.php +++ b/src/Form/Blog/CommentType.php @@ -71,6 +71,7 @@ class CommentType extends AbstractType 'label' => 'Commentaire', 'required' => true, 'attr' => [ + 'rows' => 20, ], 'constraints' => [ new NotBlank(), diff --git a/src/Form/Blog/PostType.php b/src/Form/Blog/PostType.php index b9b5dee..0b42251 100644 --- a/src/Form/Blog/PostType.php +++ b/src/Form/Blog/PostType.php @@ -250,6 +250,21 @@ class PostType extends AbstractType ], ] ); + + $builder->add( + 'notebook', + TextareaType::class, + [ + 'label' => 'Carnet de notes', + 'required' => false, + 'attr' => [ + 'data-simplemde' => '', + 'rows' => 20, + ], + 'constraints' => [ + ], + ] + ); } public function configureOptions(OptionsResolver $resolver) diff --git a/templates/blog/post_admin/_form.html.twig b/templates/blog/post_admin/_form.html.twig index 7064b1e..b0827d7 100644 --- a/templates/blog/post_admin/_form.html.twig +++ b/templates/blog/post_admin/_form.html.twig @@ -48,6 +48,9 @@ +
@@ -75,6 +78,15 @@ {% endfor %}
+
+
+ {% for item in ['notebook'] %} +
+ {{ form_row(form[item]) }} +
+ {% endfor %} +
+
diff --git a/templates/blog/post_admin/show.html.twig b/templates/blog/post_admin/show.html.twig index 8b3d8f5..395d37e 100644 --- a/templates/blog/post_admin/show.html.twig +++ b/templates/blog/post_admin/show.html.twig @@ -99,6 +99,14 @@ {% else %} {{ entity.content|markdown('post') }} {% endif %} + + {% if entity.notebook %} +
+ +
Carnet de notes
+ + {{ entity.notebook|markdown('post') }} + {% endif %}