Skip to content

Commit 7b34788

Browse files
committed
Warn about using form fields in Fluid components
And suggest to pass them as slots if needed
1 parent 841556f commit 7b34788

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Documentation/Global/Form/Index.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,35 @@ where (optional and configurable) validation occurs.
113113
Only valid data is passed on to the action and stored in
114114
the database.
115115

116+
.. _typo3-fluid-form-components:
117+
118+
Using f:form.<somefield> in Fluid components
119+
============================================
120+
121+
.. warning::
122+
123+
Form input fields like the `Form.textfield ViewHelper <f:form.textfield> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-form-textfield>`_
124+
need to find their parent form `<f:form>` within the rendering context.
125+
126+
They cannot be used in Fluid Components in TYPO3 13.4.
127+
128+
In `Components <https://docs.typo3.org/permalink/fluid:components>`_
129+
(introduced with Fluid 4.3) a new rendering context is created for
130+
each Fluid component. Therefore form fields loose the connection
131+
to their parent form and cannot be used.
132+
133+
It is however possible to pass a form field to a slot:
134+
135+
.. literalinclude:: _codesnippets/FormFieldComponent.html
136+
137+
And then use it like this:
138+
139+
.. code-block:: html
140+
141+
<my:inputWithLabel id="abc" label="My label">
142+
<f:input id="abc" property="myProperty"
143+
<my:inputWithLabel>
144+
116145
.. _typo3-fluid-form-arguments:
117146

118147
Arguments of the form ViewHelper
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<f:argument name="id" type="string" />
2+
<f:argument name="label" type="string" />
3+
4+
<div class="mb-3">
5+
<label for="{id}" class="form-label">{label}</label>
6+
<f:slot />
7+
</div>

0 commit comments

Comments
 (0)