Stefan Padberg
Stefan Padberg

Reputation: 527

TYPO3 8, Form extension - best practice for custom yaml files

When generating forms with the form module the corresponding yaml files get stored in fileadmin/user_upload.

Now I want to integrate those yaml files into my sitepackage and thus into my CVS. Where is the correct place for them? In the example extension they are stored in Resources/... while I would think they have to go into Configuration/Yaml

And how do I configure the form extension to search them in that place?

Upvotes: 1

Views: 1874

Answers (2)

sebkln
sebkln

Reputation: 1375

While it's basically a matter of taste where exactly one saves his form definitions, I try to separate form configuration and form definitions.

From the official documentation:

[...] the form configuration allows you to define:

  • which form elements, finishers, and validators are available,
  • how those objects are pre-configured,
  • how those objects will be displayed within the frontend and backend.

In contrast, the form definition describes the specific form, including

  • all form elements and their corresponding validators,
  • the order of the form elements within the form, and
  • the finishers which are fired as soon as the form has been submitted.
  • Furthermore, it defines the concrete values of each property of the mentioned aspects.

So, for more clarity I save all form configuration in a sitepackage under Configuration/Yaml/ and the form definitions under Resources/Private/Forms, neighbouring the templates.

I wrote a full tutorial how to use custom templates with EXT:form, which also includes the answers to your question.

In short:

Register YAML configuration with TypoScript in your extension root folder as ext_typoscript_setup.txt (as recommended1)

plugin.tx_form.settings.yamlConfigurations {
  100 = EXT:my_extension/Configuration/Yaml/CustomFormSetup.yaml
}

module.tx_form.settings.yamlConfigurations {
  100 = EXT:my_extension/Configuration/Yaml/CustomFormSetup.yaml
}

CustomFormSetup.yaml – setting up a new storage path

TYPO3:
  CMS:
    Form:
      persistenceManager:
        allowedExtensionPaths:
          10: EXT:my_extension/Resources/Private/Forms/
        allowSaveToExtensionPaths: true
        allowDeleteFromExtensionPaths: true

1TypoScript inside an ext_typoscript_setup.txt is automatically loaded in both frontend and backend of your TYPO3 installation directly after installing your extension. This differs from other TypoScript files, which have to be included manually, e.g. as static templates. See official Form Framework documentation.

Upvotes: 1

Mathias Brodala
Mathias Brodala

Reputation: 6460

I'd suggest Resources/Private/Forms for your form definitions. The form extension clarifies how to register additional form definition paths.

Upvotes: 0

Related Questions