0

Did the form builder type entity change drastically since symfony2 2.0? Because this code used to return a list of all my entities of type "BizTVContainerManagementBundle:ContainerSize" and now returns nothing at all, except that empty value thing...

No error message. I render the form with {{ form_widget(form) }} so nothing in the view has changed...

    $builder            
        ->add('mainContent', 'entity', array(
            'label' => 'Välj storlek på mainContent (kan inte ändras i efterhand). Endast de företag som har denna storlek på sitt mainContent kommer att få åtkomst till denna layoutmall. ',
            'property' => 'select_label',
            'class' => 'BizTVContainerManagementBundle:ContainerSize',
            ))  

* UPDATE *

Soo... turns out it is in the view after all, since I had a little custom rendering of another form control (not the one I was missing data from).

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

{% form_theme form _self %}

{% block choice_widget %}
{% spaceless %}
{% if expanded %}
    <div {{ block('widget_container_attributes') }}>
    {% for child in form %}
        {{ form_widget(child) }}
        {{ form_label(child) }}
        <br />          {# <-------- Here's my addition to the template #}
    {% endfor %}
    </div>
{% else %}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
    {% if empty_value is not none %}
        <option value="">{{ empty_value|trans }}</option>
    {% endif %}
    {% if preferred_choices|length > 0 %}
        {% set options = preferred_choices %}
        {{ block('widget_choice_options') }}
        {% if choices|length > 0 and separator is not none %}
            <option disabled="disabled">{{ separator }}</option>
        {% endif %}
    {% endif %}
    {% set options = choices %}
    {{ block('widget_choice_options') }}
</select>
{% endif %}
{% endspaceless %}
{% endblock choice_widget %}

{% block contents %}

<h1>Skapa ny skärmlayout</h1>
<div class="t_wrap">
    <form action="{{ path('createLayoutTemplate') }}" method="post" {{ form_enctype(form) }} novalidate>
        {{ form_widget(form) }}
        <p>
            <button type="submit" class="green">Skapa</button>
        </p>
    </form>

    <p>
    När du har redigerat formulär- och vy-filerna (som skapas då du klickar "skapa"), och testat att de fungerar buggfritt så behöver du klicka 'edit' på denna template och kryssa i "produktion", först då blir mallen valbar vid skapande av innehåll.
    </p>

    <a href="{{ path('listLayoutTemplates') }}"><button>Tillbaka</button></a>
</div>

{% endblock %}

And I have found that this needs to be done a different way in the 2.3 version of symfony2 (I was living in the 2.0 version). Big surprise? haha... not anymore.

I'll get back with the solution how to fix it, I have found some docs...

4

1 に答える 1