@@ -242,7 +242,7 @@ LiveProp Data Types
242
242
243
243
LiveProps must be a value that can be sent to JavaScript. Supported values
244
244
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 .
246
246
247
247
See :ref: `hydration ` for handling more complex data.
248
248
@@ -625,10 +625,33 @@ persisted entities, which dehydrate to an ``id``).
625
625
Hydration, DTO's & the Serializer
626
626
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
627
627
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
+ }
630
652
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:
632
655
633
656
1) Hydrating with the Serializer
634
657
................................
0 commit comments