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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ 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.

### Updated

## [1.2.1]
Expand Down Expand Up @@ -50,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
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/WebformController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand All @@ -199,7 +199,7 @@ public function index(): array {
'#attributes' => [
'class' => ['value'],
],
'#value' => $attributes['category'],
'#value' => implode(', ', json_decode($attributes['categories'])),
],
],

Expand Down
4 changes: 3 additions & 1 deletion src/Helper/JsonAPISerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
20 changes: 20 additions & 0 deletions src/Helper/WebformHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,26 @@ public function theme(array $existing, string $type, string $theme, string $path
* @phpstan-return array<string, mixed>
*/
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),
Expand Down
Loading