• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CPS-IT / handlebars-forms / 23287780880

19 Mar 2026 09:11AM UTC coverage: 0.0%. Remained the same
23287780880

push

github

eliashaeussler
[TASK] Provide more specific view model builder for `MultiCheckbox`

0 of 28 new or added lines in 1 file covered. (0.0%)

14 existing lines in 5 files now uncovered.

0 of 789 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/Domain/Renderable/ViewModel/MultiCheckboxViewModelBuilder.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars_forms".
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17

18
namespace CPSIT\Typo3HandlebarsForms\Domain\Renderable\ViewModel;
19

20
use TYPO3\CMS\Fluid;
21
use TYPO3\CMS\Form;
22

23
/**
24
 * MultiCheckboxViewModelBuilder
25
 *
26
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
27
 * @license GPL-2.0-or-later
28
 *
29
 * @extends AbstractViewModelBuilder<Form\Domain\Model\FormElements\GenericFormElement>
30
 */
31
final class MultiCheckboxViewModelBuilder extends AbstractViewModelBuilder
32
{
33
    protected array $supportedTypes = [
34
        'MultiCheckbox',
35
    ];
36

NEW
37
    public function renderRenderable(
×
38
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
39
        Fluid\Core\Rendering\RenderingContext $renderingContext,
40
    ): ViewModel {
NEW
41
        $options = $renderable->getProperties()['options'] ?? null;
×
42

NEW
43
        if (!is_array($options) || $options === []) {
×
NEW
44
            return new ViewModel($renderingContext);
×
45
        }
46

NEW
47
        $children = [];
×
NEW
48
        $optionIndex = 0;
×
49

NEW
50
        foreach ($options as $value => $label) {
×
NEW
51
            $checkboxResult = $this->viewHelperInvoker->invoke(
×
NEW
52
                $renderingContext,
×
NEW
53
                Fluid\ViewHelpers\Form\CheckboxViewHelper::class,
×
NEW
54
                [
×
NEW
55
                    'property' => $renderable->getIdentifier(),
×
NEW
56
                    'multiple' => true,
×
NEW
57
                    'id' => $renderable->getUniqueIdentifier() . '-' . $optionIndex++,
×
NEW
58
                    'class' => $renderable->getProperties()['elementClassAttribute'] ?? null,
×
NEW
59
                    'value' => $value,
×
NEW
60
                    'errorClass' => $renderable->getProperties()['elementErrorClassAttribute'] ?? null,
×
NEW
61
                    'additionalAttributes' => $this->renderAdditionalAttributes($renderingContext, $renderable),
×
NEW
62
                ],
×
NEW
63
            );
×
64

NEW
65
            $labelResult = $this->viewHelperInvoker->translateElementProperty(
×
NEW
66
                $renderingContext,
×
NEW
67
                $renderable,
×
NEW
68
                ['options', $value],
×
NEW
69
            );
×
70

71
            // @todo Check if this can be done in a better way
NEW
72
            $checkboxResult->tag->addAttribute('label', $labelResult);
×
73

NEW
74
            $children[] = new ViewModel($renderingContext, $checkboxResult->content, $checkboxResult->tag);
×
75
        }
76

NEW
77
        return new ViewModel($renderingContext, children: $children);
×
78
    }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc