public function LayoutPluginSelector::buildForm in Panels 8.4
Same name and namespace in other branches
- 8.3 src/Form/LayoutPluginSelector.php \Drupal\panels\Form\LayoutPluginSelector::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/ LayoutPluginSelector.php, line 63
Class
- LayoutPluginSelector
- Provides a form for selecting a layout plugin.
Namespace
Drupal\panels\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
/* @var $variant_plugin \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant */
$variant_plugin = $cached_values['plugin'];
$form['layout'] = [
'#title' => $this
->t('Layout'),
'#type' => 'select',
'#options' => $this->manager
->getLayoutOptions(),
'#default_value' => $variant_plugin
->getConfiguration()['layout'] ?: NULL,
];
$wizard = $form_state
->getFormObject();
$form['update_layout'] = [
'#type' => 'submit',
'#value' => $this
->t('Change Layout'),
'#access' => !empty($variant_plugin
->getConfiguration()['layout']),
'#validate' => [
[
$this,
'validateForm',
],
],
'#submit' => [
[
$this,
'submitForm',
],
[
$wizard,
'submitForm',
],
],
];
return $form;
}