Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9167503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:24:24+00:00 2026-06-17T15:24:24+00:00

I am generating the form in embedded controller action. And now i have faced

  • 0

I am generating the form in embedded controller action. And now i have faced the following problem. The Form Theming is not working in that case.

So what i have:

  1. The tempalte “page.html.twig”

    {% block content %}
    {% render 'MyBundle:Widget:index' %}
    {% endblock %}
    
  2. The indexAction() creates the form and rendering another template “form.html.twig” which is normally renders a form using form_row, form_rest and so on.

So, now i am trying to customize form theming, and here is my problem.
When i put the code

{% form_theme form _self %}

in the page.html.twig, i got an error the the form variable does not exists. And its correct, the form var is created later in the embedded controller.
But when i put the theming code in embedded template “form.html.twig”, i got another error “Variable “compound” does not exist”

{% block form_label %}
{% spaceless %}
    {% if not compound %}
        {% set label_attr = label_attr|merge({'for': id}) %}
    {% endif %}
    {% if required %}
        {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
    {% endif %}
    {% if label is empty %}
        {% set label = name|humanize %}
    {% endif %}
    <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %} {% if attr.tooltip is defined %}title="{{ attr.tooltip }}"{% endif %}>{{ label|trans({}, translation_domain) }}{% if required %}<span>*</span>{% endif %}</label>
{% endspaceless %}
{% endblock form_label %}

This part of code was copied from this file https://github.com/symfony/symfony/blob/2.1/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

So tried someone to do something like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:24:25+00:00Added an answer on June 17, 2026 at 3:24 pm

    Answering my question myself.

    It was a small sentence in Symfony2 docs http://symfony.com/doc/current/book/forms.html

    This {% form_theme form _self %} functionality will only work if your template extends another. If your template does not, you must point form_theme to a separate template.

    So there are two solutions to solve this problem:

    1. move form theme code to the separate file and include it in a embedded template using

      {% form_theme form with 'fields.html.twig' %}
      
    2. leave the form theme code in the same template, where the form will be generated, but extend the template from some “form.html.twig” empty template.

    I have only done the second way, and its works, but I am sure the first one will work as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic form that is generating a country list. My problem is
I have a simple form for generating reports that I am adding a jqueryUI
I'm generating several check boxes that all have the same name, when the form
A very general question. I am dynamically generating a form that is split into
I am generating a simple form with php. The following code has been reduced
I am generating a rss(xml) output form a php file. I have got a
I'm auto-generating a form in my ASP.NET page. This is already tested and working.
I have a simple content edit form (Zend_Form) that I populate() with an array
I working in Java Swing and I am generating a dynamic form with control
I have a form generating dynamic cookie, say: webform-62[1234356] 62[1234356] can be any number.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.