Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4af71a0

Browse filesBrowse files
committed
minor #20757 Add Twig field_id() form helper (alamirault)
This PR was merged into the 7.3 branch. Discussion ---------- Add Twig `field_id()` form helper Fix #20725 Commits ------- b76b199 [TwigBridge] Add Twig field_id() form helper
2 parents 409ec02 + b76b199 commit 4af71a0
Copy full SHA for 4af71a0

File tree

2 files changed

+7
-0
lines changed
Filter options

2 files changed

+7
-0
lines changed

‎form/form_customization.rst

Copy file name to clipboardExpand all lines: form/form_customization.rst
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ That's why Symfony provides other Twig form helpers that render the value of
103103
each form field part without adding any HTML around it:
104104

105105
* ``field_name()``
106+
* ``field_id()``
106107
* ``field_value()``
107108
* ``field_label()``
108109
* ``field_help()``
@@ -116,6 +117,7 @@ fields, so you no longer have to deal with form themes:
116117

117118
<input
118119
name="{{ field_name(form.username) }}"
120+
id="{{ field_id(form.username) }}"
119121
value="{{ field_value(form.username) }}"
120122
placeholder="{{ field_label(form.username) }}"
121123
class="form-control"
@@ -129,6 +131,10 @@ fields, so you no longer have to deal with form themes:
129131
{% endfor %}
130132
</select>
131133

134+
.. versionadded:: 7.3
135+
136+
The ``field_id()`` helper was introduced in Symfony 7.3.
137+
132138
Form Rendering Variables
133139
------------------------
134140

‎reference/twig_reference.rst

Copy file name to clipboardExpand all lines: reference/twig_reference.rst
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ explained in the article about :doc:`customizing form rendering </form/form_cust
408408
* :ref:`form_row() <reference-forms-twig-row>`
409409
* :ref:`form_rest() <reference-forms-twig-rest>`
410410
* :ref:`field_name() <reference-forms-twig-field-helpers>`
411+
* :ref:`field_id() <reference-forms-twig-field-helpers>`
411412
* :ref:`field_value() <reference-forms-twig-field-helpers>`
412413
* :ref:`field_label() <reference-forms-twig-field-helpers>`
413414
* :ref:`field_help() <reference-forms-twig-field-helpers>`

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.