/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); // Allow to configure the page title, even when adding a new display. // Default to the page label in that case. $form['page_title'] = ['#type' => 'textfield', '#title' => $this->t('Page title'), '#description' => $this->t('Configure the page title that will be used for this display.'), '#default_value' => $this->configuration['page_title'] ?: '']; if (empty($this->configuration['builder'])) { $plugins = $this->builderManager->getDefinitions(); $options = array(); foreach ($plugins as $id => $plugin) { $options[$id] = $plugin['label']; } $form['builder'] = ['#title' => $this->t('Builder'), '#type' => 'select', '#options' => $options, '#default_value' => 'standard']; } if (empty($this->configuration['layout'])) { $form['layout'] = ['#title' => $this->t('Layout'), '#type' => 'select', '#options' => Layout::getLayoutOptions(['group_by_category' => TRUE]), '#default_value' => NULL]; } else { $form['layout'] = ['#type' => 'value', '#value' => $this->configuration['layout']]; // If a layout is already selected, show the layout settings. $form['layout_settings_wrapper'] = ['#type' => 'fieldset', '#title' => $this->t('Layout settings')]; $form['layout_settings_wrapper']['layout_settings'] = []; // Get settings form from layout plugin. $layout = $this->layoutManager->createInstance($this->configuration['layout'], $this->configuration['layout_settings'] ?: []); $form['layout_settings_wrapper']['layout_settings'] = $layout->buildConfigurationForm($form['layout_settings_wrapper']['layout_settings'], $form_state); // Process callback to configure #parents correctly on settings, since // we don't know where in the form hierarchy our settings appear. $form['#process'][] = [$this, 'layoutSettingsProcessCallback']; } return $form; }