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

Skip to content

[TwigBridge] Add block_export() support to form attribute blocks - #65873

Open
seb-jean wants to merge 1 commit into
symfony:8.2from
seb-jean:form-attributes-function
Open

[TwigBridge] Add block_export() support to form attribute blocks#65873
seb-jean wants to merge 1 commit into
symfony:8.2from
seb-jean:form-attributes-function

Conversation

@seb-jean

@seb-jean seb-jean commented Sep 6, 2026

Copy link
Copy Markdown
Contributor
Q A
Branch? 8.2
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #65713
License MIT

Summary

  • Refactors widget_attributes, widget_container_attributes, button_attributes, and attributes blocks in form_div_layout.html.twig
  • The attributes block now builds a normalized hash (attrs), exports it via block_export(attrs), then renders HTML from that hash
  • The widget_attributes, widget_container_attributes, and button_attributes blocks set attr with proper ordering (standard attributes first, user attributes merged after) before delegating to attributes

This allows Twig Component form themes to retrieve the processed attributes as a hash using block_data(), enabling the spread syntax ({{ ...hash }}) on <twig:> components:

<twig:Input type="{{ type }}" {{ ...block_data('widget_attributes')|merge({value: value|default}) }} />

Existing form themes are not affected — block('widget_attributes') still returns the rendered HTML string as before.

Dependencies

This depends on twigphp/Twig#4920 which adds block_data() and block_export() to Twig core.

Related issue: twigphp/Twig#4919

Refactor widget_attributes, widget_container_attributes,
button_attributes, and attributes blocks so that the attributes
hash is built first, exported via block_export(), then rendered
as HTML.

This allows Twig Component form themes to retrieve the processed
attributes as a hash using block_data(), enabling the spread
syntax ({{ ...hash }}) on <twig:> components.

Existing form themes are not affected — block() still returns
the rendered HTML string as before.

See symfony#65713
Depends on twigphp/Twig#4919
@seb-jean
seb-jean force-pushed the form-attributes-function branch from cc7706d to cb66701 Compare September 6, 2026 13:11
@seb-jean seb-jean changed the title [TwigBridge] Add block_export() support to form attribute blocks [TwigBridge] Add block_export() support to form attribute blocks Sep 6, 2026
@nicolas-grekas

Copy link
Copy Markdown
Member

We need some compat code or a min-version bump of course. Also the twig merged obviously.

Status: needs work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TwigBridge] Support Twig Component form themes via block_data()/block_export()

3 participants