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

TYPO3-Headless / headless / 14022693367

23 Mar 2025 08:26PM UTC coverage: 52.345% (-20.8%) from 73.13%
14022693367

Pull #815

github

web-flow
Merge e0fcdaa4a into a15e1c8c4
Pull Request #815: [FEATURE] Add support for f:form.* viewhelper

0 of 600 new or added lines in 15 files covered. (0.0%)

1105 of 2111 relevant lines covered (52.34%)

5.94 hits per line

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

0.0
/Classes/XClass/ViewHelpers/Form/TextfieldViewHelper.php
1
<?php
2

3
/*
4
 * This file is part of the "headless" Extension for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.md file that was distributed with this source code.
8
 */
9

10
declare(strict_types=1);
11

12
/*
13
 * This file is part of the TYPO3 CMS project.
14
 *
15
 * It is free software; you can redistribute it and/or modify it under
16
 * the terms of the GNU General Public License, either version 2
17
 * of the License, or any later version.
18
 *
19
 * For the full copyright and license information, please read the
20
 * LICENSE.txt file that was distributed with this source code.
21
 *
22
 * The TYPO3 project - inspiring people to share!
23
 */
24

25
namespace FriendsOfTYPO3\Headless\XClass\ViewHelpers\Form;
26

27
/**
28
 * ViewHelper which creates a text field :html:`<input type="text">`.
29
 *
30
 * Examples
31
 * ========
32
 *
33
 * Example::
34
 *
35
 *    <f:form.textfield name="myTextBox" value="default value" />
36
 *
37
 * Output::
38
 *
39
 *    {
40
 *      "name": "tx_extension_plugin[myTextBox]",
41
 *      "type": "text",
42
 *      "value": "default value"
43
 *    }
44
 */
45
final class TextfieldViewHelper extends AbstractFormFieldViewHelper
46
{
47
    public function initializeArguments(): void
48
    {
NEW
49
        parent::initializeArguments();
×
NEW
50
        $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this ViewHelper', false, 'f3-form-error');
×
NEW
51
        $this->registerArgument('required', 'bool', 'If the field is required or not', false, false);
×
NEW
52
        $this->registerArgument('type', 'string', 'The field type, e.g. "text", "email", "url" etc.', false, 'text');
×
53
    }
54

55
    public function render(): string
56
    {
NEW
57
        $this->data = json_decode(parent::render(), true);
×
58

NEW
59
        $required = $this->arguments['required'];
×
NEW
60
        $type = $this->arguments['type'];
×
61

NEW
62
        $name = $this->getName();
×
NEW
63
        $this->registerFieldNameForFormTokenGeneration($name);
×
NEW
64
        $this->setRespectSubmittedDataValue(true);
×
65

NEW
66
        $this->data['name'] = $name;
×
NEW
67
        $this->data['type'] = $type;
×
68

NEW
69
        $value = $this->getValueAttribute();
×
70

NEW
71
        if ($value !== null) {
×
NEW
72
            $this->data['value'] = $value;
×
73
        }
74

NEW
75
        if ($required !== false) {
×
NEW
76
            $this->data['required'] = $required;
×
NEW
77
            $this->tag->addAttribute('required', 'required');
×
78
        }
79

NEW
80
        $this->addAdditionalIdentityPropertiesIfNeeded();
×
NEW
81
        $this->setErrorClassAttribute();
×
82

NEW
83
        return json_encode($this->data);
×
84
    }
85
}
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