Skip to content

Commit 82a6a45

Browse files
authored
Merge pull request #16 from OS2Forms/feature/various-fixes
Feature/various fixes
2 parents 8670239 + 6589ec2 commit 82a6a45

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).
99

1010
## [Unreleased]
1111

12+
## [1.3.0]
13+
14+
- Handled webform categories now being an array.
15+
- Rendered wizard pages as 'details' elements in previews.
16+
1217
### Updated
1318

1419
## [1.2.1]
@@ -50,7 +55,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
5055

5156
- Added OS2Forms sync module
5257

53-
[Unreleased]: https://github.com/itk-dev/os2forms_sync/compare/1.2.1...HEAD
58+
[Unreleased]: https://github.com/itk-dev/os2forms_sync/compare/1.3.0...HEAD
59+
[1.3.0]: https://github.com/itk-dev/os2forms_sync/compare/1.2.1...1.3.0
5460
[1.2.1]: https://github.com/itk-dev/os2forms_sync/compare/1.2.0...1.2.1
5561
[1.2.0]: https://github.com/itk-dev/os2forms_sync/compare/1.1.3...1.2.0
5662
[1.1.3]: https://github.com/itk-dev/os2forms_sync/compare/1.1.2...1.1.3

src/Controller/WebformController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function index(): array {
184184
'#type' => 'container',
185185
'#attributes' => [
186186
'class' => ['category'],
187-
'data-indexed' => strip_tags($attributes['category']),
187+
'data-indexed' => implode(', ', json_decode($attributes['categories'])),
188188
],
189189

190190
'label' => [
@@ -199,7 +199,7 @@ public function index(): array {
199199
'#attributes' => [
200200
'class' => ['value'],
201201
],
202-
'#value' => $attributes['category'],
202+
'#value' => implode(', ', json_decode($attributes['categories'])),
203203
],
204204
],
205205

src/Helper/JsonAPISerializer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ static function ($key) {
8080
return in_array($key, [
8181
'title',
8282
'description',
83-
'category',
83+
'categories',
8484
'elements',
8585
]);
8686
},
8787
ARRAY_FILTER_USE_KEY
8888
);
8989

90+
$attributes['categories'] = json_encode($attributes['categories']);
91+
9092
$attributes = array_map('html_entity_decode', $attributes);
9193

9294
if (isset($attributes['elements'])) {

src/Helper/WebformHelper.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ public function theme(array $existing, string $type, string $theme, string $path
175175
* @phpstan-return array<string, mixed>
176176
*/
177177
public function getSubmissionForm(array $elements): array {
178+
179+
// Webforms that are rendered here are not a part of the database yet.
180+
// As a consequence, any element that attempts to load the webform will be
181+
// unable to do so.
182+
// Wizard pages attempt to do so in WebformWizardPage::showPage, so we
183+
// display these as 'details' instead and indicate that they originally
184+
// are pages in their titles.
185+
$isFirst = TRUE;
186+
foreach ($elements as &$element) {
187+
if (($element['#type'] ?? NULL) === 'webform_wizard_page') {
188+
if ($isFirst) {
189+
$element['#open'] = TRUE;
190+
$isFirst = FALSE;
191+
}
192+
193+
$element['#type'] = 'details';
194+
$element['#title'] = (string) $this->t('%title% (wizard page)', ['%title%' => $element['#title']]);
195+
}
196+
}
197+
178198
$webform = Webform::create([
179199
'id' => (new Random())->name(32),
180200
'elements' => Yaml::encode($elements),

0 commit comments

Comments
 (0)