You are here

protected function YamlFormEntityForm::editForm in YAML Form 8

Edit form element's source code form.

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.

1 call to YamlFormEntityForm::editForm()
YamlFormEntityForm::form in src/YamlFormEntityForm.php
Gets the actual form array to be built.
1 method overrides YamlFormEntityForm::editForm()
YamlFormUiEntityForm::editForm in modules/yamlform_ui/src/YamlFormUiEntityForm.php
Edit form element's source code form.

File

src/YamlFormEntityForm.php, line 181

Class

YamlFormEntityForm
Base for controller for form.

Namespace

Drupal\yamlform

Code

protected function editForm(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\yamlform\YamlFormInterface $yamlform */
  $yamlform = $this
    ->getEntity();
  $t_args = [
    ':form_api_href' => 'https://www.drupal.org/node/37775',
    ':render_api_href' => 'https://www.drupal.org/developing/api/8/render',
    ':yaml_href' => 'https://en.wikipedia.org/wiki/YAML',
  ];
  $form['elements'] = [
    '#type' => 'yamlform_codemirror',
    '#mode' => 'yaml',
    '#title' => $this
      ->t('Elements (YAML)'),
    '#description' => $this
      ->t('Enter a <a href=":form_api_href">Form API (FAPI)</a> and/or a <a href=":render_api_href">Render Array</a> as <a href=":yaml_href">YAML</a>.', $t_args) . '<br/>' . '<em>' . $this
      ->t('Please note that comments are not supported and will be removed.') . '</em>',
    '#default_value' => $yamlform
      ->get('elements'),
    '#required' => TRUE,
  ];
  $form['token_tree_link'] = $this->tokenManager
    ->buildTreeLink();
  return $form;
}