Skip to content

Commit 95a622c

Browse files
committed
minor #986 chore(doc): explain ComponentWithFormTrait getDataModelValue override (94noni)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- chore(doc): explain ComponentWithFormTrait getDataModelValue override | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Tickets | improve doc Commits ------- 82b7245 chore(doc): explain ComponentWithFormTrait getDataModelValue override
2 parents 98fb623 + 82b7245 commit 95a622c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,21 @@ clicked). To do that, use ``norender`` modifier:
352352

353353
<input data-model="norender|max">
354354

355+
For a form using ``ComponentWithFormTrait``, override the ``getDataModelValue()`` method::
356+
357+
private function getDataModelValue(): ?string
358+
{
359+
return 'norender|*';
360+
}
361+
362+
.. tip::
363+
364+
You can also define this value inside Twig::
365+
366+
.. code-block:: html+twig
367+
368+
{{ form_start(form, {attr: {'data-model': 'norender|*'}}) }}
369+
355370
Now, as you type, the ``max`` "model" will be updated in JavaScript, but
356371
it won't, yet, make an Ajax call to re-render the component. Whenever
357372
the next re-render *does* happen, the updated ``max`` value will be

0 commit comments

Comments
 (0)