src/DoctrineORMModule/Form/Annotation/AnnotationBuilder.php
public function getFormSpecification($entity)
    {
        $formSpec     = parent::getFormSpecification($entity);
        $metadata     = $this->objectManager->getClassMetadata(is_object($entity) ? get_class($entity) : $entity);
        $inputFilter  = $formSpec['input_filter'];

        $formElements = [
            Element\ObjectSelect::class,
            Element\ObjectMultiCheckbox::class,
            Element\ObjectRadio::class,
        ];

        foreach ($formSpec['elements'] as $key => $elementSpec) {
            $name          = $elementSpec['spec']['name'] ?? null;
            $isFormElement = (isset($elementSpec['spec']['type']) &&
                              in_array($elementSpec['spec']['type'], $formElements));

            if (! $name) {
                continue;
            }

            if (! isset($inputFilter[$name])) {
                $inputFilter[$name] = new \ArrayObject();
            }

            $params = [
                'metadata'    => $metadata,
                'name'        => $name,
                'elementSpec' => $elementSpec,
                'inputSpec'   => $inputFilter[$name],
            ];

            if ($this->checkForExcludeElementFromMetadata($metadata, $name)) {
                $elementSpec = $formSpec['elements'];
                unset($elementSpec[$key]);
                $formSpec['elements'] = $elementSpec;

                if (isset($inputFilter[$name])) {
                    unset($inputFilter[$name]);
                }

                $formSpec['input_filter'] = $inputFilter;
                continue;
            }

            if ($metadata->hasField($name) || (! $metadata->hasAssociation($name) && $isFormElement)) {
                $this->getEventManager()->trigger(static::EVENT_CONFIGURE_FIELD, $this, $params);
            } elseif ($metadata->hasAssociation($name)) {
                $this->getEventManager()->trigger(static::EVENT_CONFIGURE_ASSOCIATION, $this, $params);
            }
        }

        $formSpec['options'] = ['prefer_form_input_filter' => true];

        return $formSpec;
    }
public function getFormSpecification($entity)
    {
        $formSpec     = parent::getFormSpecification($entity);
        $metadata     = $this->objectManager->getClassMetadata(is_object($entity) ? get_class($entity) : $entity);
        $inputFilter  = $formSpec['input_filter'];

        $formElements = [
            Element\ObjectSelect::class,
            Element\ObjectMultiCheckbox::class,
            Element\ObjectRadio::class,
        ];

        foreach ($formSpec['elements'] as $key => $elementSpec) {
            $name          = $elementSpec['spec']['name'] ?? null;
            $isFormElement = (isset($elementSpec['spec']['type']) &&
                              in_array($elementSpec['spec']['type'], $formElements));

            if (! $name) {
                continue;
            }

            if (! isset($inputFilter[$name])) {
                $inputFilter[$name] = new \ArrayObject();
            }

            $params = [
                'metadata'    => $metadata,
                'name'        => $name,
                'elementSpec' => $elementSpec,
                'inputSpec'   => $inputFilter[$name],
            ];

            if ($this->checkForExcludeElementFromMetadata($metadata, $name)) {
                $elementSpec = $formSpec['elements'];
                unset($elementSpec[$key]);
                $formSpec['elements'] = $elementSpec;

                if (isset($inputFilter[$name])) {
                    unset($inputFilter[$name]);
                }

                $formSpec['input_filter'] = $inputFilter;
                continue;
            }

            if ($metadata->hasField($name) || (! $metadata->hasAssociation($name) && $isFormElement)) {
                $this->getEventManager()->trigger(static::EVENT_CONFIGURE_FIELD, $this, $params);
            } elseif ($metadata->hasAssociation($name)) {
                $this->getEventManager()->trigger(static::EVENT_CONFIGURE_ASSOCIATION, $this, $params);
            }
        }

        $formSpec['options'] = ['prefer_form_input_filter' => true];

        return $formSpec;
    }
public function getFormSpecification ( $ entity ) { $ formSpec = parent :: getFormSpecification ( $ entity ) ; $ metadata = $ this -> objectManager -> getClassMetadata ( is_object ( $ entity ) ? get_class ( $ entity ) : $ entity ) ; $ inputFilter = $ formSpec [ 'input_filter' ] ; $ formElements = [ Element \ ObjectSelect :: class , Element \ ObjectMultiCheckbox :: class , Element \ ObjectRadio :: class , ] ; foreach ( $ formSpec [ 'elements' ] as $ key => $ elementSpec ) { $ name = $ elementSpec [ 'spec' ] [ 'name' ] ?? null ; $ isFormElement = ( isset ( $ elementSpec [ 'spec' ] [ 'type' ] ) && in_array ( $ elementSpec [ 'spec' ] [ 'type' ] , $ formElements ) ) ; if ( ! $ name ) { continue ; } if ( ! isset ( $ inputFilter [ $ name ] ) ) { $ inputFilter [ $ name ] = new \ ArrayObject ( ) ; } $ params = [ 'metadata' => $ metadata , 'name' => $ name , 'elementSpec' => $ elementSpec , 'inputSpec' => $ inputFilter [ $ name ] , ] ; if ( $ this -> checkForExcludeElementFromMetadata ( $ metadata , $ name ) ) { $ elementSpec = $ formSpec [ 'elements' ] ; unset ( $ elementSpec [ $ key ] ) ; $ formSpec [ 'elements' ] = $ elementSpec ; if ( isset ( $ inputFilter [ $ name ] ) ) { unset ( $ inputFilter [ $ name ] ) ; } $ formSpec [ 'input_filter' ] = $ inputFilter ; continue ; } if ( $ metadata -> hasField ( $ name ) || ( ! $ metadata -> hasAssociation ( $ name ) && $ isFormElement ) ) { $ this -> getEventManager ( ) -> trigger ( static :: EVENT_CONFIGURE_FIELD , $ this , $ params ) ; } elseif ( $ metadata -> hasAssociation ( $ name ) ) { $ this -> getEventManager ( ) -> trigger ( static :: EVENT_CONFIGURE_ASSOCIATION , $ this , $ params ) ; } } $ formSpec [ 'options' ] = [ 'prefer_form_input_filter' => true ] ; return $ formSpec ; }
Overrides the base getFormSpecification() to additionally iterate through each
field/association in the metadata and trigger the associated event.

This allows building of a form from metadata instead of requiring annotations.
Annotations are still allowed through the ElementAnnotationsListener.

{@inheritDoc}
Overrides the base getFormSpecification () to additionally iterate through each field / association in the metadata and trigger the associated event .