You are here

public function ProcessedText::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 YamlFormMarkupBase::form

File

src/Plugin/YamlFormElement/ProcessedText.php, line 57

Class

ProcessedText
Provides a 'processed_text' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function form(array $form, FormStateInterface $form_state) {

  // Issue #2741877 Nested modals don't work: when using CKEditor in a
  // modal, then clicking the image button opens another modal,
  // which closes the original modal.
  // @todo Remove the below workaround once this issue is resolved.
  if (!$form_state
    ->getUserInput() && \Drupal::currentUser()
    ->hasPermission('administer yamlform')) {
    drupal_set_message($this
      ->t('Processed text element can not be opened within a modal. Please see <a href="https://www.drupal.org/node/2741877">Issue #2741877: Nested modals don\'t work</a>.'), 'warning');
  }
  $form = parent::form($form, $form_state);

  // Remove 'Submission display' since the 'format' property is handled by
  // the text format element.
  unset($form['display']);
  $form['markup']['#title'] = $this
    ->t('Processed text settings');
  $form['markup']['text'] = [
    '#type' => 'text_format',
    '#format' => '',
  ];
  return $form;
}