8000 [TwigBridge][Form] Use of Spaceless in Form's Textarea Widget Can Strip Whitespace Only Values · Issue #11277 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chrisguitarguy opened this issue Jul 3, 2014 · 0 comments

Comments

@chrisguitarguy
Copy link
Contributor

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 %}
chrisguitarguy added a commit to chrisguitarguy/symfony that referenced this issue Jul 3, 2014
chrisguitarguy added a commit to chrisguitarguy/symfony that referenced this issue Jul 13, 2014
In favor of using Twig's whitespace control operators. See symfony#11277
fabpot added a commit that referenced this issue Jul 14, 2014
…targuy)

This PR was merged into the 2.3 branch.

Discussion
----------

Remove Spaceless Blocks from Twig Form Templates

In favor of using Twig's whitespace control operators. See #11277

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11277
| License       | MIT
| Doc PR        |

Per @fabpot and @stof's requests in #11278, this is a PR for the 2.3 branch.

Commits
-------

8f9ed3e Remove Spaceless Blocks from Twig Form Templates
@fabpot fabpot closed this as completed Jul 14, 2014
fabpot added a commit that referenced this issue Jul 15, 2014
This PR was submitted for the master branch but it was merged into the 2.4 branch instead (closes #11278).

Discussion
----------

Remove Spaceless Blocks From Twig Templates

Leaving it in can only mangle values from data bound to the form.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11277
| License       | MIT
| Doc PR        |

The tests pass here, but it doesn't seem like any tests really cover the actual rendering.

Commits
-------

793a083 Remove Spaceless Blocks From Twig Templates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0