Skip to content

Commit

Permalink
minor #986 chore(doc): explain ComponentWithFormTrait getDataModelVal…
Browse files Browse the repository at this point in the history
…ue 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
  • Loading branch information
weaverryan committed Oct 5, 2023
2 parents 98fb623 + 82b7245 commit 95a622c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/LiveComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,21 @@ clicked). To do that, use ``norender`` modifier:

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

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

Check failure on line 366 in src/LiveComponent/doc/index.rst

View workflow job for this annotation

GitHub Actions / DOCtor-RST

Please use "twig" instead of "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
Expand Down

0 comments on commit 95a622c

Please sign in to comment.