score:3

Accepted answer

You have to call the form_widget and form_label for the answer type

{{ form_label(question.Answer) }}
{{ form_widget(question.Answer) }}

score:0

You need to define the block question_row in a form theme, and use {{ form(questionaire_form) }} to render the entire form.

Acme/DemoBundle/Form/Type/QuestionType.php

// ...

public function getName(){
    return 'question';
}

// ...

Acme/DemoBundle/Controller/DefaultController.php

// ...

public function questionaireAction(){

    $form = $this->createForm(new BriefQuestionaireType());

    return $this->render('AcmeDemoBundle:Default:brief_questionaire.html.twig', array(
        'questionaire_form' => $form->createView()
    ));

}

// ...

Acme/DemoBundle/Resources/views/Default/brief_questionaire.html.twig

<html>
    <head>
        <title>Questionaire</title>
    </head>
    <body>
        {% form_theme questionaire_form 'AcmeDemoBundle:Form:form.html.twig' %}
        {{ form(questionaire_form) }}
    </body>
</html>

Acme/DemoBundle/Resources/views/Form/form.html.twig

We create a block named [block_prefix]_row, where block_prefix is derived from getName() in QuestionType above. When this form theme is used, all QuestionType rows are rendered this way.

{% block question_row %}
    <div class="question">
        {{ form_label(form) }}
    </div>
    <div>
        {{ form_widget(form) }}
        {{ form_error(form) }}              
    </div>
{% endblock %}

Related Query

More Query from same tag