sf_tristanb
sf_tristanb

Reputation: 8855

Symfony CollectionType: this value is not valid (TransformationFailedException)

I'm facing a weird error when customizing the form theme "This value is not valid" when submitting a form containing a collection.

When the form is not customized, it's working as excepted. When it's working, the name of an entry is example[expOnlines][0][name] when it's not it looks like example[expOnlines][0]

{% block _cv_expOnlines_widget %}
    <div class="col-md-12 mb-3">
        {{ block('collection_add_button') }}
    </div>

    <div class="c-form__field col-md-12">
        {{ block('collection_widget') }}
    </div>
{% endblock %}

{% block _cv_expOnlines_entry_row %}
    <div class="py-3 row" {{ block('row_container_attributes') }}>
        <div class="col-md-9">
            {{ block('form_widget_simple') }}
        </div>
        <div class="col-auto">
            {{ block('collection_delete_button') }}
        </div>
    </div>
{% endblock %}

PHP side (but the bug is not there, because it only happens when overriding the form_theme)

enter image description here

This errors appears on all my CollectionType on the form

Upvotes: 1

Views: 402

Answers (1)

sf_tristanb
sf_tristanb

Reputation: 8855

Well, I was missing an important point,

It's not a form_widget_simple block. Instead I should do : {{ block('form_widget') }}

That fixed the problem.

Upvotes: 2

Related Questions