You are here

public function YamlFormCompositeBase::form in YAML Form 8

Gets the actual configuration form array to be built.

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 An associative array contain the element's configuration form without any default values..

Overrides YamlFormElementBase::form

1 call to YamlFormCompositeBase::form()
YamlFormLocation::form in src/Plugin/YamlFormElement/YamlFormLocation.php
Gets the actual configuration form array to be built.
1 method overrides YamlFormCompositeBase::form()
YamlFormLocation::form in src/Plugin/YamlFormElement/YamlFormLocation.php
Gets the actual configuration form array to be built.

File

src/Plugin/YamlFormElement/YamlFormCompositeBase.php, line 221

Class

YamlFormCompositeBase
Provides a base for composite elements.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  // Update #default_value description.
  $form['general']['default_value']['#description'] = $this
    ->t("The default value of the composite form element as YAML.");

  // Update #required label.
  $form['validation']['required']['#description'] .= '<br/>' . $this
    ->t("Checking this option only displays the required indicator next to this element's label. Please chose which elements should be required below.");
  $form['composite'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('@title settings', [
      '@title' => $this
        ->getPluginLabel(),
    ]),
  ];
  $form['composite']['elements'] = $this
    ->buildCompositeElementsTable();
  $form['composite']['flexbox'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Use Flexbox'),
    '#description' => $this
      ->t("If 'Automatic' is selected Flexbox layout will only be used if a Flexbox element is included in the form."),
    '#options' => [
      '' => $this
        ->t('Automatic'),
      0 => $this
        ->t('No'),
      1 => $this
        ->t('Yes'),
    ],
  ];
  return $form;
}