Doctrine Embedded with Annotations for forms

Hi,

For some low important/low interactivity forms I am using Forms using Annotations.

I am also using Embeddables and I just started to create forms for Entities having Embeddables. I dont quite understand how to work with the Embeddables using Fieldsets because on saving data it seems there is no correct hydrate between form array and the embeddable object.

/**
 * @ORM\Entity(repositoryClass="FormatRepo")
 * @ORM\Table(name="format")
 * @Annotation\Name("format")
 */
class Format {
/**
 * @ORM\Embedded(class="\Application\Entity\BasicDimension", columnPrefix="length")
 *
 * @Annotation\Name("length")
 * @Annotation\Type("BasicDimensionFieldset")
 * @Annotation\Options({"label":"Length"})
 */
protected ?BasicDimension $length = null;

....
}

So, when hydrating, the data seems to not hydrate the Emebeddable as I am getting…

Argument 1 passed to Format::setLength() must be an instance of BasicDimension or null, array given, called in /vendor/doctrine/doctrine-laminas-hydrator/src/DoctrineObject.php on line 378

Any idea how to use the embeddables with annotations for forms?

I dont necessary want to create the Fieldset Separated, maybe it could use the annotations from embeddable?

My Configuration is:
PHP 7.4 (can’t migrate to 8.0 right now)
laminas/laminas-form 2.17.0
doctrine/doctrine-orm-module 3.2.2

I cant migrate to doctrine/doctrine-orm-module 4 as thats not supporting the DocBlock annotations and also because the app cant be migrated now to 8.0 I cant migrate DocBlock to PHP attributes…

But where does the name BasicDimensionFieldset come from?

Thats an actual Fieldset. I dont want to create a Form Fieldset if I can use directly the annotations from the Embeddable…

But I dont know how to do it.

Unfortunately, this was not clear from your post.

I do not use PHP8 attributes or DocBlock annotations and unfortunately I don’t know who can help here. Please try to ask in the Doctrine community or on Slack.