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

Skip to content

[TwigBridge][Form] Use of Spaceless in Form's Textarea Widget Can Strip Whitespace Only Values #11277

Closed
@chrisguitarguy

Description

@chrisguitarguy

Say you have a textarea field -- it's not being trimmed and whitespace-only is a valid value. Maybe you're letting users write and save whitespace code or something.

When rendering a text area with only whitespace as a value, it will disappear. the {% spaceless %} block strips it out.

This doesn't seem correct: if whitespace-only is a valid value, the form component and twig bridge shouldn't mess with it.

Work around: use a custom form theme without spaceless. This could also be the fix for this issue.

{# in some twig template #}

{% form_theme someVariableWithAFormView _self %}

{% block textarea_widget %}
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
{% endblock textarea_widget %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions