public function DebugWebformHandler::submitForm in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformHandler/DebugWebformHandler.php \Drupal\webform\Plugin\WebformHandler\DebugWebformHandler::submitForm()
Submit webform submission 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.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
Overrides WebformHandlerBase::submitForm
File
- src/
Plugin/ WebformHandler/ DebugWebformHandler.php, line 126
Class
- DebugWebformHandler
- Webform submission debug handler.
Namespace
Drupal\webform\Plugin\WebformHandlerCode
public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
$settings = $this
->getSettings();
$data = $settings['submission'] ? $webform_submission
->toArray(TRUE) : $webform_submission
->getData();
WebformElementHelper::convertRenderMarkupToStrings($data);
$label = $settings['submission'] ? $this
->t('Submitted properties and values are:') : $this
->t('Submitted values are:');
$build = [
'label' => [
'#markup' => $label,
],
'data' => [
'#markup' => $settings['format'] === static::FORMAT_JSON ? json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRETTY_PRINT) : WebformYaml::encode($data),
'#prefix' => '<pre>',
'#suffix' => '</pre>',
],
];
$message = $this->renderer
->renderPlain($build);
$this
->messenger()
->addWarning($message);
}