pti/pti-forms

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

v4.0.1 2024-08-29 14:02 UTC

This package is auto-updated.

Last update: 2024-09-30 14:25:50 UTC


README

Helper classes to render extbase forms in a PTI context. The classes act as replacements for the fluid view helpers:

  • AbstractFormFieldViewHelper
  • FormViewHelper

Their main concern is to render the correct field names for the form fields and the hidden fields that extbase requires to accept the form submission.

Sample usage

$form = GeneralUtility::makeInstance(Form::class);
$form->setRequest($this->request);
$form->setObjectName('contactForm'); // optional

$messageField = GeneralUtility::makeInstance(TextArea::class);
$messageField->setProperty('message');
$form->addField($messageField)

$form = $form->render();
/*
[
    'fields' => [
        'message' => [
            'name' => 'tx_extension_plugin[contactForm][message]',
            'value' => '',
        ],
    ],
    'hiddenFields' => [
        [
            'name' => 'tx_extension_plugin[__referrer][@extension]',
            'value' => 'Extension'
        ],
        [
            'name' => 'tx_extension_plugin[__trustedProperties]',
            'value' => '…',
        ],

    ],
]
*/

$form['action'] = …
$form['method'] = …

Most extensions will extend the Field class to create select fields, textareas, etc.