[SOLVED] How to display inputs created in the form type – Symfony 6.0.2


This Content is from Stack Overflow. Question asked by Emilie Tossan

I created a form type in SearchType.php file. But when I try to display the form in search.html.twig file, none of the inputs is displayed. I tried to write {{ form(form) }} in the html.twig file and see what I have. I find myself with an empty text input instead of two selects as expected.

How do I display inputs created in my form type ?



namespace AppForm;

use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentOptionsResolverOptionsResolver;
use SymfonyComponentFormExtensionCoreTypeChoiceType;

class SearchType extends AbstractType
    public function buildForm(FormBuilderInterface $builder, array $options): void
            ->add('bigcity', ChoiceType::class, [
                'choices' => [
                    'Je sélectionne une ville' => '',
                    'Paris, France' => 'paris'
            ->add('category', ChoiceType::class, [
                'choices' => [
                    "Je sélectionne un type d'activité" => '',
                    'Eat Zpeak !' => 'eatzpeak',
                    'Party Zpeak !' => 'partyzpeak',
                    'Run Zpeak !' => 'runzpeak',
                    'Art Zpeak !' => 'artzpeak',
            ->add('save', SubmitType::class)

    public function configureOptions(OptionsResolver $resolver): void
            'data_class' => null


{% extends 'base.html.twig' %}

{% block title %}Liste des sorties et des activités !{% endblock %}

{% block main %}

<div class="position-relative">

    <div class="position-absolute top-50 start-50 translate-middle">
        {{ form_start(form) }}
            {{ form_widget(form.bigcity) }}
            {{ form_widget(form.category) }}
        {{ form_end(form) }}


{% endblock %}

I have this error :

Neither the property "bigcity" nor one of the methods exist and have public access in class



namespace AppController;

use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyComponentFormExtensionCoreTypeSearchType;
use SymfonyBundleFrameworkBundleControllerAbstractController;

class EventsController extends AbstractController
    #[Route('/search', name: 'search')]
    public function search(Request $request)
        $form = $this->createForm(SearchType::class);
        return $this->render('front/search.html.twig', [
            'form' => $form->createView()


Same issue as your previous post the namespace is wrong in the controller the searchType should be App\Form\SearchType instead of Symfony\Component\Form\Extension\Core\Type\SearchType in your EventsController class

This Question was asked in StackOverflow by Emilie Tossan and Answered by Youssef Saoubou It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?