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

CPS-IT / handlebars-forms / 23788866234

31 Mar 2026 08:52AM UTC coverage: 0.659% (-0.06%) from 0.72%
23788866234

push

github

web-flow
Merge pull request #18 from CPS-IT/feature/view-models

0 of 163 new or added lines in 33 files covered. (0.0%)

7 of 1062 relevant lines covered (0.66%)

0.03 hits per line

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

0.0
/Classes/Domain/ViewModel/Builder/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\ViewModel\Builder;
19

20
use CPSIT\Typo3HandlebarsForms\Domain;
21
use TYPO3\CMS\Fluid;
22
use TYPO3\CMS\Form;
23

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

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

46
        if (!is_array($options)) {
×
47
            $options = [];
×
48
        }
49

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

NEW
65
            $checkboxViewModel = new Domain\ViewModel\ViewHelperContainedViewModel($renderable, $checkboxResult);
×
66
            $labelResult = $this->viewHelperInvoker->translateElementProperty(
×
67
                $renderingContext,
×
68
                $renderable,
×
69
                ['options', $value],
×
70
            );
×
71

72
            if (is_string($labelResult)) {
×
NEW
73
                $children[] = Domain\ViewModel\FormFieldViewModel::forLabelAndElement($labelResult, $checkboxViewModel);
×
74
            } else {
NEW
75
                $children[] = $checkboxViewModel;
×
76
            }
77
        }
78

NEW
79
        return new Domain\ViewModel\ViewModelCollection($renderable, $children);
×
80
    }
81
}
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