Skip to content

Commit 30d4fdb

Browse files
author
matheo
committed
add doc
1 parent 9d738d6 commit 30d4fdb

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ LiveProp Data Types
242242

243243
LiveProps must be a value that can be sent to JavaScript. Supported values
244244
are scalars (int, float, string, bool, null), arrays (of scalar values), enums,
245-
DateTime objects & Doctrine entity objects.
245+
DateTime objects, Doctrine entity objects, DTO, or array of DTO.
246246

247247
See :ref:`hydration` for handling more complex data.
248248

@@ -625,10 +625,33 @@ persisted entities, which dehydrate to an ``id``).
625625
Hydration, DTO's & the Serializer
626626
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
627627

628-
If you try to use a ``LiveProp`` for some unsupported type (e.g.a DTO object),
629-
it will fail. A best practice is to use simple data.
628+
.. versionadded:: 2.11
629+
630+
Dto are now a supported type for LiveComponent
631+
632+
To use a ``LiveProp`` with DTO simply type properly your property
633+
634+
.. code-block:: php
635+
636+
class ComponentWithAddressDto
637+
{
638+
public AddressDto $addressDto;
639+
}
640+
641+
And to work with DTO collection, you simply need to specified the collection type in your phpdoc
642+
643+
.. code-block:: php
644+
645+
class ComponentWithAddressDto
646+
{
647+
/**
648+
* @var AddressDto[]
649+
/*
650+
public array $addressDtoCollection;
651+
}
630652
631-
But there are two options to make this work:
653+
If this solution doesn't feat your need
654+
there are two others options to make this work:
632655

633656
1) Hydrating with the Serializer
634657
................................

0 commit comments

Comments
 (0)