Skip to content
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

Enable rendering Symfony Forms fields in FieldGroup #1283

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

dlouhak
Copy link
Contributor

@dlouhak dlouhak commented Feb 14, 2024

  • This is hotfix solution to be able render Symfony Forms fields[SFF] inside FieldGroup. There is no problem to render other components such as Text, Radio or more complex Accordion.
  • I will explain how I get to the solution below.
  • Better solutions and explanations are welcomed. 🙏

There's something I don't understand.

  1. ❌ Current implementation
{% if block('content') is not empty %}
    <div class="{{ _fieldsClassName }}">
        {% block content %}{% endblock %}
    </div>
{% endif %}
  • Not possible to render SFF (via form_row or form_widget), but form_label is rendered! 🤯
  • SFF isn't even in the dump(block('content')) log.
  1. ❌ Store block('content') into the variable
{% if block('content') is not empty %}
    {% set _children = block('content') %}

    <div class="{{ _fieldsClassName }}">
        {{ _children }}
    </div>
{% endif %}
  • Still not possible to render SFF and it isn't seen in the dump(_children) log.
  1. ✅ Store block('content') into the variable outside the implementation
{# API #}
…
{% set _children = block('content') %}
…

{% if _children is not empty %}
    <div class="{{ _fieldsClassName }}">
        {{ _children | raw }}
    </div>
{% endif %}
  • Finally – I can see the SFF in the dump(_children) and is it possible to render it – but because it was stored in a variable it was converted to a string, so raw filter is here to help.

@dlouhak dlouhak added bug Something isn't working documentation Improvements or additions to documentation labels Feb 14, 2024
@dlouhak dlouhak self-assigned this Feb 14, 2024
Copy link

netlify bot commented Feb 14, 2024

Deploy Preview for spirit-design-system-storybook canceled.

Name Link
🔨 Latest commit 24227cf
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-storybook/deploys/65ce01224c74d70008710fea

Copy link

netlify bot commented Feb 14, 2024

Deploy Preview for spirit-design-system-demo canceled.

Name Link
🔨 Latest commit 24227cf
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-demo/deploys/65ce01227c08a800097969f0

Copy link

netlify bot commented Feb 14, 2024

Deploy Preview for spirit-design-system-validations canceled.

Name Link
🔨 Latest commit 24227cf
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-validations/deploys/65ce0122f3d4d10008558946

@coveralls
Copy link

coveralls commented Feb 14, 2024

Coverage Status

coverage: 72.818%. remained the same
when pulling 24227cf on fix/enable-rendering-symfony-forms-fields-in-fieldgroup
into 84ef862 on main.

Copy link

netlify bot commented Feb 14, 2024

Deploy Preview for spirit-design-system-react canceled.

Name Link
🔨 Latest commit 24227cf
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-react/deploys/65ce01220063f80008f13619

@literat literat force-pushed the fix/enable-rendering-symfony-forms-fields-in-fieldgroup branch from eadf2e5 to 5306559 Compare February 15, 2024 10:18
@dlouhak dlouhak marked this pull request as ready for review February 15, 2024 10:19
@literat literat force-pushed the fix/enable-rendering-symfony-forms-fields-in-fieldgroup branch from c2d94cb to 24227cf Compare February 15, 2024 12:18
@dlouhak
Copy link
Contributor Author

dlouhak commented Feb 15, 2024

Works on my machine! 🖥️ ✅

Thanks @literat and @adamkudrna for the discussion and quick handling of the issue. ❤️

@literat literat merged commit 7e69912 into main Feb 15, 2024
35 checks passed
@literat literat deleted the fix/enable-rendering-symfony-forms-fields-in-fieldgroup branch February 15, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants