You are here

public function PanelizerWizardGeneralForm::buildForm in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 src/Form/PanelizerWizardGeneralForm.php \Drupal\panelizer\Form\PanelizerWizardGeneralForm::buildForm()
  2. 8.3 src/Form/PanelizerWizardGeneralForm.php \Drupal\panelizer\Form\PanelizerWizardGeneralForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/PanelizerWizardGeneralForm.php, line 105

Class

PanelizerWizardGeneralForm
General settings for a panelized bundle.

Namespace

Drupal\panelizer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $cached_values = $form_state
    ->getTemporaryValue('wizard');

  /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */
  $plugin = $cached_values['plugin'];
  $form_state = new FormState();
  $form_state
    ->setValues($form_state
    ->getValue('variant_settings', []));
  $settings = $plugin
    ->buildConfigurationForm([], $form_state);

  // If the entity view display supports custom Panelizer layouts, force use
  // of the in-place editor. Right now, there is no other way to work with
  // custom layouts.
  if (isset($cached_values['id'])) {
    list($this->entityTypeId, $this->bundle, $this->viewMode) = explode('__', $cached_values['id']);
  }
  $panelizer_settings = $this->panelizer
    ->getPanelizerSettings($this->entityTypeId, $this->bundle, $this->viewMode);
  if (!empty($panelizer_settings['custom'])) {
    $settings['builder']['#default_value'] = 'ipe';
    $settings['builder']['#access'] = FALSE;
  }
  $settings['#tree'] = TRUE;
  $form['variant_settings'] = $settings;
  return $form;
}