Symfony : CreateForm / Why my textarea do not appear?

  css, forms, symfony, symfony4

I have a problem to display a textarea from a form I’ve created with Symfony.

The textarea appears in html but it has no display: block in the css. It has nothing in the css, to be clear.

When I add a display:block in the css myself, it simply stripped by chrome/firefox.

The problem only happens when I create the form from a separate Class, not when I create it in controller’s function.

Here is my code:



namespace AppController;

use AppEntityAd;
use AppFormAdType;
use AppRepositoryAdRepository;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyBundleFrameworkBundleControllerAbstractController;

class AdController extends AbstractController

     * Create ad
     * @Route("/ads/new", name="ads_create")
     * @return Response
    public function create(){

         $ad = new Ad();

         $form = $this->createForm(AdType::class, $ad);

        return $this->render('ad/new.html.twig', [
            'form' => $form->createView()




namespace AppForm;

use AppEntityAd;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentOptionsResolverOptionsResolver;
use SymfonyComponentFormExtensionCoreTypeTextareaType;

class AdType extends AbstractType
    public function buildForm(FormBuilderInterface $builder, array $options)
            ->add('content', TextareaType::class, [
                'attr' => array('cols' => '5', 'rows' => '5')])

    public function configureOptions(OptionsResolver $resolver)
            'data_class' => Ad::class,

And twig :

{% extends 'base.html.twig' %}
{% form_theme form 'bootstrap_4_layout.html.twig' %}

{% block title %}Create ad{% endblock %}

{% block body %}
    <div class="container">
        <h1>lorem ipsum</h1>


            {{ form(form) }}


{% endblock %}

I tried a lot of things but I still don’t understand how to solve this problem. Do someone have an idea about it ?

Thanks in advance !

Source: Symfony Questions