Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Handled errors in form preview

## [1.1.0]

### Added
Expand Down
14 changes: 13 additions & 1 deletion src/Controller/WebformController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,19 @@ public function index(): array {
else {
foreach ($webforms as $webform) {
$attributes = $webform->attributes;
$form = $this->webformHelper->getSubmissionForm($attributes['elements']);
try {
$form = $this->webformHelper->getSubmissionForm($attributes['elements']);
}
catch (\Throwable $t) {
$form = [
'#theme' => 'status_messages',
'#message_list' => [
'error' => [
$this->t('Cannot render form: @message', ['@message' => $t->getMessage()]),
],
],
];
}
// Make sure that the form cannot be submitted (hopefully).
$form['#attributes']['onsubmit'] = 'return false';

Expand Down