From af518d8ab3567349dbee7a1b11495540ac33acce Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Mon, 10 Nov 2025 15:31:54 +0100 Subject: [PATCH 1/4] Handled rendering of wizard pages in previews --- src/Helper/WebformHelper.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Helper/WebformHelper.php b/src/Helper/WebformHelper.php index 520892e..1ec4f48 100644 --- a/src/Helper/WebformHelper.php +++ b/src/Helper/WebformHelper.php @@ -175,6 +175,26 @@ public function theme(array $existing, string $type, string $theme, string $path * @phpstan-return array */ public function getSubmissionForm(array $elements): array { + + // Webforms that are rendered here are not a part of the database yet. + // As a consequence, any element that attempts to load the webform will be + // unable to do so. + // Wizard pages attempt to do so in WebformWizardPage::showPage, so we + // display these as 'details' instead and indicate that they originally + // are pages in their titles. + $isFirst = TRUE; + foreach ($elements as &$element) { + if (($element['#type'] ?? NULL) === 'webform_wizard_page') { + if ($isFirst) { + $element['#open'] = TRUE; + $isFirst = FALSE; + } + + $element['#type'] = 'details'; + $element['#title'] = (string) $this->t('%title% (wizard page)', ['%title%' => $element['#title']]); + } + } + $webform = Webform::create([ 'id' => (new Random())->name(32), 'elements' => Yaml::encode($elements), From a5ca4d664a657d7110f6b2c3ef7aebd30ecfc1fa Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Mon, 10 Nov 2025 15:32:35 +0100 Subject: [PATCH 2/4] Handled webforms now allowing multiple categories --- src/Controller/WebformController.php | 4 ++-- src/Helper/JsonAPISerializer.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Controller/WebformController.php b/src/Controller/WebformController.php index c4e3233..42b5d03 100644 --- a/src/Controller/WebformController.php +++ b/src/Controller/WebformController.php @@ -184,7 +184,7 @@ public function index(): array { '#type' => 'container', '#attributes' => [ 'class' => ['category'], - 'data-indexed' => strip_tags($attributes['category']), + 'data-indexed' => implode(', ', json_decode($attributes['categories'])), ], 'label' => [ @@ -199,7 +199,7 @@ public function index(): array { '#attributes' => [ 'class' => ['value'], ], - '#value' => $attributes['category'], + '#value' => implode(', ', json_decode($attributes['categories'])), ], ], diff --git a/src/Helper/JsonAPISerializer.php b/src/Helper/JsonAPISerializer.php index 13b6c97..b10e154 100644 --- a/src/Helper/JsonAPISerializer.php +++ b/src/Helper/JsonAPISerializer.php @@ -80,13 +80,15 @@ static function ($key) { return in_array($key, [ 'title', 'description', - 'category', + 'categories', 'elements', ]); }, ARRAY_FILTER_USE_KEY ); + $attributes['categories'] = json_encode($attributes['categories']); + $attributes = array_map('html_entity_decode', $attributes); if (isset($attributes['elements'])) { From f008710286aacc432eeb0af90c73e48b30286194 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Mon, 10 Nov 2025 15:32:46 +0100 Subject: [PATCH 3/4] Updated CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63f298f..01627bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Handled webform categories now being an array. +- Rendered wizard pages as 'details' elements in previews. + ### Updated ## [1.2.1] From 6589ec2fe025c9eb5123a23aa60ab5003343f8df Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Tue, 11 Nov 2025 09:23:40 +0100 Subject: [PATCH 4/4] Release 1.3.0 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01627bd..0f5280e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [1.3.0] + - Handled webform categories now being an array. - Rendered wizard pages as 'details' elements in previews. @@ -53,7 +55,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). - Added OS2Forms sync module -[Unreleased]: https://github.com/itk-dev/os2forms_sync/compare/1.2.1...HEAD +[Unreleased]: https://github.com/itk-dev/os2forms_sync/compare/1.3.0...HEAD +[1.3.0]: https://github.com/itk-dev/os2forms_sync/compare/1.2.1...1.3.0 [1.2.1]: https://github.com/itk-dev/os2forms_sync/compare/1.2.0...1.2.1 [1.2.0]: https://github.com/itk-dev/os2forms_sync/compare/1.1.3...1.2.0 [1.1.3]: https://github.com/itk-dev/os2forms_sync/compare/1.1.2...1.1.3