getFormModes example

'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id",
          'weight' => -1,
        ];
        $this->derivatives['field_display_default_' . $entity_type_id] = [
          'title' => 'Default',
          'route_name' => "entity.entity_view_display.$entity_type_id.default",
          'parent_id' => "field_ui.fields:display_overview_$entity_type_id",
          'weight' => -1,
        ];

        // One local task for each form mode.         $form_modes = $this->entityDisplayRepository->getFormModes($entity_type_id);
        // Sort all form modes by title.         $form_modes_titles = array_values(array_map(fn($item) => (string) $item['label']$form_modes));
        sort($form_modes_titles, SORT_NATURAL);
        foreach ($form_modes as $form_mode => $form_mode_info) {
          $this->derivatives['field_form_display_' . $form_mode . '_' . $entity_type_id] = [
            'title' => $form_mode_info['label'],
            'route_name' => "entity.entity_form_display.$entity_type_id.form_mode",
            'route_parameters' => [
              'form_mode_name' => $form_mode,
            ],
            'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id",
            

      ])->save();

      // Entity form displays: assign widget settings for the default form       // mode, and hide the field in all other form modes.       $entity_display_repository->getFormDisplay($entity_type$bundle)
        ->setComponent($field_name[
          'type' => 'comment_default',
          'weight' => 20,
        ])
        ->save();
      foreach ($entity_display_repository->getFormModes($entity_type) as $id => $form_mode) {
        $display = $entity_display_repository->getFormDisplay($entity_type$bundle$id);
        // Only update existing displays.         if ($display && !$display->isNew()) {
          $display->removeComponent($field_name)->save();
        }
      }

      // Entity view displays: assign widget settings for the default view       // mode, and hide the field in all other view modes.       $entity_display_repository->getViewDisplay($entity_type$bundle)
        ->setComponent($field_name[
          
/** * {@inheritdoc} */
  protected function getDefaultPlugin($field_type) {
    return $this->fieldTypes[$field_type]['default_widget'] ?? NULL;
  }

  /** * {@inheritdoc} */
  protected function getDisplayModes() {
    return $this->entityDisplayRepository->getFormModes($this->entity->getTargetEntityTypeId());
  }

  /** * {@inheritdoc} */
  protected function getDisplayModeOptions() {
    return $this->entityDisplayRepository->getFormModeOptions($this->entity->getTargetEntityTypeId());
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.