Adding forms for creating and editing entities
In our BO controllers, we use two forms: one for the category and one for the posts. As the category form is really simple, we will focus on the blog post creation/edition form. It follows the same concept as in the previous chapter form builder extension, but it’s a nice way to rediscover it in another context.
As a reminder, a form is defined by a structure definition type for our form and the data provider for inputs to prefill before display.
First, let’s create the /modules/whblog/src/Form/Type/WHBlogPostType.php
file to implement the field structure for our form as follows:
class WHBlogPostType extends TranslatorAwareType { private $categoryRepository; private $categoriesChoiceTree; public function __construct($translator, $locales, $categoryRepository) { parent::__construct($translator, $locales); $this...