Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Form Choice options with hidden labels 2.8 #17773

Closed
@dazorni

Description

@dazorni

Hi,

we updated from Symfony 2.6 to 2.8 with the choice options you can find below.
We expected the label of our choice type should be hidden and just the value and the input element exists. In 2.6 this worked for us.

When we upgraded to 2.8 (with the same options) the labels are shown again. The Problem is caused by an empty string in the view, not as expected false.

$resolver->setDefaults([
    'choices' => [1 => false, 2 => false, 3 => false, 4 => false, 5 => false],
    'expanded' => true,
    'placeholder' => false,
    'required' => false,
]);

So we added a workaround in our bootstrap_3_layout.html.twig to resolve this.

{%- block radio_label -%}
    {% if label == '' or label is null %}
        {% set label = false %}
    {% endif %}

    {{ parent() }}
{%- endblock radio_label -%}

Is there a cleaner way to hide the label or is this a bug/bc break?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions