Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy