src/Form/PageParts/InsertPagePagePartAdminType.php
public function finishView(FormView $view, FormInterface $form, array $options)
    {
        $data = $form->getData();
        if ($data instanceof InsertPagePagePart) {

            $this->validateParentPage();

            $reflections = [];
            $nodeFormView = $view->children['node'];
            /** @var ChoiceView $choice */
            foreach ($nodeFormView->vars['choices'] as $choice) {
                /** @var Node $currentData */
                $currentData = $choice->data;

                $entityCls = $currentData->getRefEntityName();
                if (!array_key_exists($entityCls, $reflections)) {
                    $reflections[$entityCls] = new \ReflectionClass($entityCls);
                }

                // only the pages with the right interface are selectable
                if (!$reflections[$entityCls]->implementsInterface(InsertablePageInterface::class)) {
                    $choice->attr['disabled'] = 'disabled';
                }
            }
        }
    }
public function finishView(FormView $view, FormInterface $form, array $options)
    {
        $data = $form->getData();
        if ($data instanceof InsertPagePagePart) {

            $this->validateParentPage();

            $reflections = [];
            $nodeFormView = $view->children['node'];
            /** @var ChoiceView $choice */
            foreach ($nodeFormView->vars['choices'] as $choice) {
                /** @var Node $currentData */
                $currentData = $choice->data;

                $entityCls = $currentData->getRefEntityName();
                if (!array_key_exists($entityCls, $reflections)) {
                    $reflections[$entityCls] = new \ReflectionClass($entityCls);
                }

                // only the pages with the right interface are selectable
                if (!$reflections[$entityCls]->implementsInterface(InsertablePageInterface::class)) {
                    $choice->attr['disabled'] = 'disabled';
                }
            }
        }
    }
public function finishView ( FormView $ view , FormInterface $ form , array $ options ) { $ data = $ form -> getData ( ) ; if ( $ data instanceof InsertPagePagePart ) { $ this -> validateParentPage ( ) ; $ reflections = [ ] ; $ nodeFormView = $ view -> children [ 'node' ] ; /** @var ChoiceView $choice */ foreach ( $ nodeFormView -> vars [ 'choices' ] as $ choice ) { /** @var Node $currentData */ $ currentData = $ choice -> data ; $ entityCls = $ currentData -> getRefEntityName ( ) ; if ( ! array_key_exists ( $ entityCls , $ reflections ) ) { $ reflections [ $ entityCls ] = new \ ReflectionClass ( $ entityCls ) ; } // only the pages with the right interface are selectable if ( ! $ reflections [ $ entityCls ] -> implementsInterface ( InsertablePageInterface :: class ) ) { $ choice -> attr [ 'disabled' ] = 'disabled' ; } } } }
We want to set disable the parent page to prevent infinity insert cycle. If it is an edit page, we can disable this
from form's data.

@param FormView      $view
@param FormInterface $form
@param array         $options
We want to set disable the parent page to prevent infinity insert cycle . If it is an edit page we can disable this from form s data .