You are here

public function YamlFormCodeMirror::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

File

src/Plugin/YamlFormElement/YamlFormCodeMirror.php, line 93

Class

YamlFormCodeMirror
Provides a 'yamlform_codemirror' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $form['codemirror'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('CodeMirror settings'),
  ];
  $form['codemirror']['mode'] = [
    '#title' => $this
      ->t('Mode'),
    '#type' => 'select',
    '#options' => [
      'yaml' => $this
        ->t('YAML'),
      'html' => $this
        ->t('HTML'),
      'text' => $this
        ->t('Plain text'),
    ],
    '#required' => TRUE,
  ];
  return $form;
}