WebformMarkup.php in Webform 6.x
File
src/Plugin/WebformElement/WebformMarkup.php
View source
<?php
namespace Drupal\webform\Plugin\WebformElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Mail\MailFormatHelper;
use Drupal\webform\WebformSubmissionInterface;
class WebformMarkup extends WebformMarkupBase {
protected function defineDefaultProperties() {
return [
'wrapper_attributes' => [],
'markup' => '',
] + parent::defineDefaultProperties();
}
public function buildText(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
if (isset($element['#markup'])) {
$element['#markup'] = MailFormatHelper::htmlToText($element['#markup']);
}
return parent::buildText($element, $webform_submission, $options);
}
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['markup']['markup'] = [
'#type' => 'webform_html_editor',
'#title' => $this
->t('HTML markup'),
'#description' => $this
->t('Enter custom HTML into your webform.'),
];
return $form;
}
}