Skip to main navigation Skip to main content Skip to page footer

Form Definition

Forms are defined in the frontend via TypoScript. A distinction is made between forms for creating (Create) and editing (Edit) records. The basic configuration takes place under plugin.tx_modules.settings.forms.

Basic Configuration

Each form is configured via a unique identifier (e.g. addressCreate or address).

plugin.tx_modules.settings.forms.myFormIdentifier {
    # Database table to which the form refers
    table = tx_extension_domain_model_example

    # Storage location for new records (only relevant for creation)
    storagePid = 123

    # Default values for new records (only relevant for creation)
    defaults {
        hidden = 0
        deleted = 0
        # Type of the model, if necessary (full class name)
        # type = CodingMs\Extension\Domain\Model\Example
    }

    # Notification on saving
    mailOnSave {
        active = 1
        subject = Neuer Datensatz erstellt
        fromEmail = sender@example.com
        toEmail = receiver@example.com
    }

    # Messages for the user
    messages {
        error {
            title = Fehler
            savingFailed = Bitte überprüfen Sie Ihre Eingaben.
        }
        success {
            title = Erfolg
            successfullySaved = Ihre Daten wurden erfolgreich gespeichert.
        }
    }

    # Definition of form fields
    fieldsets {
        # ...
    }
}

Fieldsets and Fields

The form is divided into fieldsets. Usually there is a general fieldset for the input fields and a buttons fieldset for the actions.

Fields are mostly copied from predefined presets provided in plugin.tx_modules.presets.fields.

    fieldsets {
        general < plugin.tx_modules.presets.fieldsets.normal
        general {
            label = Allgemein
            fields {
                # Example for a text field
                company < plugin.tx_modules.presets.fields.input
                company {
                    label = Firma
                    placeholder = Musterfirma GmbH
                    required = 0
                    validation {
                        NotEmpty = Bitte geben Sie eine Firma ein
                    }
                }
            }
        }

        # Buttons at the end of the form
        buttons < plugin.tx_modules.presets.fieldsets.buttons
        buttons {
            fields {
                submit < plugin.tx_modules.presets.fields.submit
                submit {
                    label = Speichern
                    css.class.wrapper = form-group form-input-submit float-start me-1
                }
                cancelAndBackToListButton < plugin.tx_modules.presets.fields.cancelAndBackToListButton
                cancelAndBackToListButton {
                    label = Abbrechen
                    css.class.wrapper = form-group form-input-submit float-start me-1
                }
            }
        }
    }

Available Field Types (Presets)

The following presets are available under plugin.tx_modules.presets.fields:

  • input - Simple text field
  • textarea - Multiline text field
  • rte - Rich Text Editor
  • checkbox - Checkbox (e.g. for terms and conditions or boolean values)
  • checkboxes - Multiple selection via checkboxes (relations)
  • select - Selection box (Dropdown)
  • selectCountry - Country selection
  • files - File upload (requires corresponding configuration for relations)
  • inputDate - Date field
  • inputDateTime - Date and time field
  • inputEmail - E-mail field with validation
  • inputSlug - URL segment field
  • hidden - Hidden field

Validation

Validators can be defined per field in the validation block. The key is the name of the validator, the value is the error message displayed if validation fails.

More on this under Available Validators.

validation {
    NotEmpty = Dieses Feld ist ein Pflichtfeld
    Email = Bitte geben Sie eine gültige E-Mail Adresse ein
}

Multilanguage Support

Labels and error messages can be overridden depending on the language via TypoScript conditions:

[siteLanguage("locale") == "de-DE"]
plugin.tx_modules.settings.forms.myFormIdentifier {
    messages {
        success.successfullySaved = Datensatz gespeichert
    }
    fieldsets {
        general {
            label = Allgemein
            fields {
                company {
                    label = Firma
                    validation {
                        NotEmpty = Bitte geben Sie eine Firma ein
                    }
                }
            }
        }
    }
}
[GLOBAL]
Shopping basket 0 Products

The Demo is build with*

EXT:bootstrap_package for site-package aka theme build on Bootsrap 5.

EXT:modules for user plugins like user-profile, registration, user-addresses, and more.

EXT:shop for the whole shop functionality.

EXT:questions for the FAQ page and FAQs attached in the product detail views.

EXT:glossaries for the glossaries and definitions.

EXT:fluid_fpdf for generating invoices, delivery-notes, product-sheets and more.

EXT:parsedown_extra for rendering the extension documentations from markdown to HTML.

* There are only build-in settings made using site-settings & TypoScript – no templates or other files were changed or overridden!