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

FluidTYPO3 / flux / 17904759627

15 Sep 2025 08:47AM UTC coverage: 90.676% (-2.1%) from 92.767%
17904759627

push

github

NamelessCoder
[TASK] Set beta stability

6924 of 7636 relevant lines covered (90.68%)

9.49 hits per line

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

90.48
/Classes/ViewHelpers/Form/OptionViewHelper.php
1
<?php
2
declare(strict_types=1);
3
namespace FluidTYPO3\Flux\ViewHelpers\Form;
4

5
/*
6
 * This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.md file that was distributed with this source code.
10
 */
11

12
use FluidTYPO3\Flux\Form\OptionCarryingInterface;
13
use FluidTYPO3\Flux\ViewHelpers\AbstractFormViewHelper;
14
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
15

16
/**
17
 * Form option ViewHelper
18
 */
19
class OptionViewHelper extends AbstractFormViewHelper
20
{
21
    public static string $option = '';
22

23
    public function initializeArguments(): void
24
    {
25
        $this->registerArgument('value', 'string', 'Option value');
1✔
26
        $this->registerArgument('name', 'string', 'Name of the option to be set', true);
1✔
27
    }
28

29
    public function render()
30
    {
31
        return self::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
×
32
    }
33

34
    public static function renderStatic(
35
        array $arguments,
36
        \Closure $renderChildrenClosure,
37
        RenderingContextInterface $renderingContext
38
    ): string {
39
        /** @var string $option */
40
        $option = $arguments['name'] ?? static::$option;
7✔
41
        $container = static::getContainerFromRenderingContext($renderingContext);
7✔
42
        $value = $renderChildrenClosure();
7✔
43
        if ($container instanceof OptionCarryingInterface) {
7✔
44
            $container->setOption($option, $value);
6✔
45
            return '';
6✔
46
        }
47
        throw new \UnexpectedValueException(
1✔
48
            'flux:form.option cannot be used as child element of '
1✔
49
            . get_class($container)
1✔
50
            . ' (this class does not support options). '
1✔
51
            . 'Please correct this in your template file(s). The option had name="'
1✔
52
            . $option
1✔
53
            . '" and value="'
1✔
54
            . $value
1✔
55
            . '"',
1✔
56
            1602693000
1✔
57
        );
1✔
58
    }
59

60
    public function getContentArgumentName(): ?string
61
    {
62
        return 'value';
×
63
    }
64
}
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