From 82b7245a0f63b0ccb32507b8d3dafdf3a7ba8113 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Tue, 4 Jul 2023 14:51:20 +0200 Subject: [PATCH] chore(doc): explain ComponentWithFormTrait getDataModelValue override --- src/LiveComponent/doc/index.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/LiveComponent/doc/index.rst b/src/LiveComponent/doc/index.rst index 57e9a2c5453..b7d23d192bd 100644 --- a/src/LiveComponent/doc/index.rst +++ b/src/LiveComponent/doc/index.rst @@ -352,6 +352,21 @@ clicked). To do that, use ``norender`` modifier: +For a form using ``ComponentWithFormTrait``, override the ``getDataModelValue()`` method:: + + private function getDataModelValue(): ?string + { + return 'norender|*'; + } + +.. tip:: + + You can also define this value inside Twig:: + + .. code-block:: html+twig + + {{ form_start(form, {attr: {'data-model': 'norender|*'}}) }} + Now, as you type, the ``max`` "model" will be updated in JavaScript, but it won't, yet, make an Ajax call to re-render the component. Whenever the next re-render *does* happen, the updated ``max`` value will be