@@ -813,7 +813,12 @@ recreate the *same* form, we pass in the ``Post`` object and set it as a
813813``LiveProp ``.
814814
815815The template for this component will render the form, which is available
816- as ``this.form `` thanks to the trait:
816+ as ``form `` thanks to the trait:
817+
818+ .. versionadded :: 2.1
819+
820+ The ability to access ``form `` directly in your component's template
821+ was added in LiveComponents 2.1. Previously ``this.form `` was required.
817822
818823.. code-block :: twig
819824
@@ -833,13 +838,13 @@ as ``this.form`` thanks to the trait:
833838 #}
834839 data-action="change->live#update"
835840 >
836- {{ form_start(this. form) }}
837- {{ form_row(this. form.title) }}
838- {{ form_row(this. form.slug) }}
839- {{ form_row(this. form.content) }}
841+ {{ form_start(form) }}
842+ {{ form_row(form.title) }}
843+ {{ form_row(form.slug) }}
844+ {{ form_row(form.content) }}
840845
841846 <button>Save</button>
842- {{ form_end(this. form) }}
847+ {{ form_end(form) }}
843848 </div>
844849
845850 Mostly, this is a pretty boring template! It includes the normal
@@ -1027,7 +1032,7 @@ Finally, tell the ``form`` element to use this action:
10271032 {# templates/components/post_form.html.twig #}
10281033 {# ... #}
10291034
1030- {{ form_start(this. form, {
1035+ {{ form_start(form, {
10311036 attr: {
10321037 'data-action': 'live#action',
10331038 'data-action-name': 'prevent|save'
@@ -1148,11 +1153,11 @@ and ``removeComment()`` actions:
11481153.. code-block :: twig
11491154
11501155 <div{{ attributes }}>
1151- {{ form_start(this. form) }}
1152- {{ form_row(this. form.title) }}
1156+ {{ form_start(form) }}
1157+ {{ form_row(form.title) }}
11531158
11541159 <h3>Comments:</h3>
1155- {% for key, commentForm in this. form.comments %}
1160+ {% for key, commentForm in form.comments %}
11561161 <button
11571162 data-action="live#action"
11581163 data-action-name="removeComment(index={{ key }})"
@@ -1164,7 +1169,7 @@ and ``removeComment()`` actions:
11641169 </div>
11651170
11661171 {# avoid an extra label for this field #}
1167- {% do this. form.comments.setRendered %}
1172+ {% do form.comments.setRendered %}
11681173
11691174 <button
11701175 data-action="live#action"
@@ -1173,7 +1178,7 @@ and ``removeComment()`` actions:
11731178 >+ Add Comment</button>
11741179
11751180 <button type="submit" >Save</button>
1176- {{ form_end(this. form) }}
1181+ {{ form_end(form) }}
11771182 </div>
11781183
11791184 Done! Behind the scenes, it works like this:
0 commit comments