getLayoutOptions example

$form['field_layouts'] = [
      '#type' => 'details',
      '#title' => $this->t('Layout settings'),
    ];

    $layout_plugin = $this->getLayout($this->getEntity()$form_state);

    $form['field_layouts']['field_layout'] = [
      '#type' => 'select',
      '#title' => $this->t('Select a layout'),
      '#options' => $this->layoutPluginManager->getLayoutOptions(),
      '#default_value' => $layout_plugin->getPluginId(),
      '#ajax' => [
        'callback' => '::settingsAjax',
        'wrapper' => 'field-layout-settings-wrapper',
        'trigger_as' => ['name' => 'field_layout_change'],
      ],
    ];
    $form['field_layouts']['submit'] = [
      '#type' => 'submit',
      '#name' => 'field_layout_change',
      '#value' => $this->t('Change layout'),
      
Home | Imprint | This part of the site doesn't use cookies.