From 5afae215949d62a4f9236ef6b460ab87746a1d77 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 19 Jun 2018 13:22:27 +0200 Subject: [PATCH] Add help messages to some form fields --- src/Form/CommentType.php | 5 ++++- src/Form/PostType.php | 3 +++ templates/blog/_comment_form.html.twig | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Form/CommentType.php b/src/Form/CommentType.php index 19626fe8a..803d32112 100644 --- a/src/Form/CommentType.php +++ b/src/Form/CommentType.php @@ -13,6 +13,7 @@ use App\Entity\Comment; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -40,7 +41,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) // $builder->add('content', null, ['required' => false]); $builder - ->add('content') + ->add('content', TextareaType::class, [ + 'help' => 'Comments not complying with our Code of Conduct will be moderated.', + ]) ; } diff --git a/src/Form/PostType.php b/src/Form/PostType.php index c15e237f3..fad5792ce 100644 --- a/src/Form/PostType.php +++ b/src/Form/PostType.php @@ -48,14 +48,17 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'label.title', ]) ->add('summary', TextareaType::class, [ + 'help' => 'Summaries can\'t contain Markdown or HTML contents; only plain text.', 'label' => 'label.summary', ]) ->add('content', null, [ 'attr' => ['rows' => 20], + 'help' => 'Use Markdown to format the blog post contents. HTML is allowed too.', 'label' => 'label.content', ]) ->add('publishedAt', DateTimePickerType::class, [ 'label' => 'label.published_at', + 'help' => 'Set the date in the future to schedule the blog post publication.', ]) ->add('tags', TagsInputType::class, [ 'label' => 'label.tags', diff --git a/templates/blog/_comment_form.html.twig b/templates/blog/_comment_form.html.twig index c9a9e9c90..800a2fd52 100644 --- a/templates/blog/_comment_form.html.twig +++ b/templates/blog/_comment_form.html.twig @@ -28,6 +28,7 @@ {{ form_errors(form.content) }} {{ form_widget(form.content, {attr: {rows: 10}}) }} + {{ form_help(form.content) }}