Skip to content

Commit 82b7245

Browse files
94noniweaverryan
authored andcommitted
chore(doc): explain ComponentWithFormTrait getDataModelValue override
1 parent 046e580 commit 82b7245

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)