• 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/ButtonViewHelper.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
 * Creates a button.
29
 *
30
 * Examples
31
 * ========
32
 *
33
 * Defaults::
34
 *
35
 *    <f:form.button>Send Mail</f:form.button>
36
 *
37
 * Output::
38
 *
39
 *    {
40
 *        "type": "submit"
41
 *        "content": "Send mail"
42
 *    }
43
 *
44
 * Disabled cancel button with some HTML5 attributes::
45
 *
46
 *    <f:form.button type="reset" disabled="disabled"
47
 *        name="buttonName" value="buttonValue"
48
 *        formmethod="post" formnovalidate="formnovalidate"
49
 *    >
50
 *        Cancel
51
 *    </f:form.button>
52
 *
53
 * Output::
54
 *
55
 *    {
56
 *      "disabled": "disabled",
57
 *      "formmethod": "post",
58
 *      "formnovalidate": "formnovalidate",
59
 *      "name": "tx_extension_plugin[buttonName]",
60
 *      "type": "reset",
61
 *      "value": "buttonValue",
62
 *      "content": "Cancel"
63
 *    },
64
 */
65
final class ButtonViewHelper extends AbstractFormFieldViewHelper
66
{
67
    public function initializeArguments(): void
68
    {
NEW
69
        parent::initializeArguments();
×
NEW
70
        $this->registerArgument('type', 'string', 'Specifies the type of button (e.g. "button", "reset" or "submit")', false, 'submit');
×
71
    }
72

73
    public function render(): string
74
    {
NEW
75
        $this->data = json_decode(parent::render(), true);
×
76

NEW
77
        $type = $this->arguments['type'];
×
NEW
78
        $name = $this->getName();
×
NEW
79
        $this->registerFieldNameForFormTokenGeneration($name);
×
80

NEW
81
        $this->data['name'] = $name;
×
NEW
82
        $this->data['type'] = $type;
×
83

NEW
84
        $value = $this->getValueAttribute();
×
85

NEW
86
        if ($value !== null) {
×
NEW
87
            $this->data['value'] = $value;
×
88
        }
89

NEW
90
        $this->data['content'] = (string)$this->renderChildren();
×
91

NEW
92
        return json_encode($this->data);
×
93
    }
94
}
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