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

FluidTYPO3 / flux / 12237686280

09 Dec 2024 02:27PM UTC coverage: 92.9% (-0.5%) from 93.421%
12237686280

push

github

NamelessCoder
[TER] 10.1.0

7013 of 7549 relevant lines covered (92.9%)

56.22 hits per line

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

98.59
/Classes/ViewHelpers/FieldViewHelper.php
1
<?php
2
declare(strict_types=1);
3
namespace FluidTYPO3\Flux\ViewHelpers;
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\Field;
13
use FluidTYPO3\Flux\Form\FieldContainerInterface;
14
use FluidTYPO3\Flux\Form\FieldInterface;
15
use FluidTYPO3\Flux\ViewHelpers\Field\AbstractFieldViewHelper;
16
use TYPO3Fluid\Fluid\Component\Argument\ArgumentCollection;
17
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18

19
/**
20
 * FlexForm field ViewHelper
21
 *
22
 * Defines a single field data structure.
23
 */
24
class FieldViewHelper extends AbstractFieldViewHelper
25
{
26
    public function initializeArguments(): void
27
    {
28
        $this->registerArgument('type', 'string', 'TCA field type', true);
6✔
29
        $this->registerArgument('name', 'string', 'Name of the attribute, FlexForm XML-valid tag name string', true);
6✔
30
        $this->registerArgument('label', 'string', 'Label for field');
6✔
31
        $this->registerArgument('description', 'string', 'Field description', false);
6✔
32
        $this->registerArgument('exclude', 'bool', 'Set to FALSE if field is not an "exclude" field', false, false);
6✔
33
        $this->registerArgument('config', 'array', 'TCA "config" array', false, []);
6✔
34
        $this->registerArgument(
6✔
35
            'transform',
6✔
36
            'string',
6✔
37
            'Set this to transform your value to this type - integer, array (for csv values), float, DateTime, ' .
6✔
38
            'Vendor\\MyExt\\Domain\\Model\\Object or ObjectStorage with type hint.'
6✔
39
        );
6✔
40
        $this->registerArgument(
6✔
41
            'onChange',
6✔
42
            'string',
6✔
43
            'TCA onChange instruction',
6✔
44
            false
6✔
45
        );
6✔
46
        $this->registerArgument(
6✔
47
            'displayCond',
6✔
48
            'string',
6✔
49
            'Optional "Display Condition" (TCA style) for this particular field. See: ' .
6✔
50
            'https://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#displaycond'
6✔
51
        );
6✔
52
        $this->registerArgument(
6✔
53
            'inherit',
6✔
54
            'boolean',
6✔
55
            'If TRUE, the value for this particular field is inherited - if inheritance is enabled by ' .
6✔
56
            'the ConfigurationProvider',
6✔
57
            false,
6✔
58
            true
6✔
59
        );
6✔
60
        $this->registerArgument(
6✔
61
            'inheritEmpty',
6✔
62
            'boolean',
6✔
63
            'If TRUE, allows empty values (specifically excluding the number zero!) to be inherited - if inheritance ' .
6✔
64
            'is enabled by the ConfigurationProvider',
6✔
65
            false,
6✔
66
            true
6✔
67
        );
6✔
68
        $this->registerArgument(
6✔
69
            'clear',
6✔
70
            'boolean',
6✔
71
            'If TRUE, a "clear value" checkbox is displayed next to the field which when checked, completely ' .
6✔
72
            'destroys the current field value all the way down to the stored XML value.',
6✔
73
            false,
6✔
74
            false
6✔
75
        );
6✔
76
        $this->registerArgument(
6✔
77
            'protect',
6✔
78
            'boolean',
6✔
79
            'If TRUE, a "protect value" checkbox is displayed next to the field which when checked, protects the ' .
6✔
80
            'value from being changed if the (normally inherited) field value is changed in a parent record. Has no ' .
6✔
81
            'effect if "inherit" is disabled on the field.',
6✔
82
            false,
6✔
83
            false
6✔
84
        );
6✔
85
        $this->registerArgument(
6✔
86
            'extensionName',
6✔
87
            'string',
6✔
88
            'If provided, enables overriding the extension context for this and all child nodes. The extension name ' .
6✔
89
            'is otherwise automatically detected from rendering context.'
6✔
90
        );
6✔
91
    }
92

93
    public static function getComponent(
94
        RenderingContextInterface $renderingContext,
95
        iterable $arguments
96
    ): FieldInterface {
97
        /** @var array $arguments */
98
        $parent = static::getContainerFromRenderingContext($renderingContext);
12✔
99
        $field = Field::create($arguments instanceof ArgumentCollection ? $arguments->getArrayCopy() : $arguments);
12✔
100
        $field->setClearable($arguments['clear']);
12✔
101
        $field->setProtectable($arguments['protect']);
12✔
102

103
        if (!$parent instanceof FieldContainerInterface) {
12✔
104
            return $field;
×
105
        }
106

107
        $parent->add($field);
12✔
108
        return $field;
12✔
109
    }
110
}
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