You are here

public function ProcessedText::form in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/ProcessedText.php \Drupal\webform\Plugin\WebformElement\ProcessedText::form()

Gets the actual configuration webform 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 webform without any default values.

Overrides WebformMarkupBase::form

File

src/Plugin/WebformElement/ProcessedText.php, line 100

Class

ProcessedText
Provides a 'processed_text' element.

Namespace

Drupal\webform\Plugin\WebformElement

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() && $this->currentUser
    ->hasPermission('administer webform')) {
    $this
      ->messenger()
      ->addWarning($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>.'));
  }
  $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;
}