TYPEMILL

Forms with Typemill

Last updated: 27.02.2020

Whenever a user wants to customize something, he will probably do it with forms. TYPEMILL provides an easy and flexible way to generate such forms on the fly. Developers can define forms with simple YAML definitions and users (authors) can use such forms for different purposes:

Basics

You can define forms in the YAML configuration files of your plugin and your theme.

A very simple form configuration looks like this:

forms:
  fields:

    myfieldname:
      type: text
      label: Add a short text

    anotherfield:
      type: textarea
      label:  Add a long text

The rules are pretty simple:

Typemill will use these definitions to generate the form with all input fields on the fly.

If a user fills out the form and clicks on save, then Typemill will store the input data. Developer have access to the input data in various ways.

A short example: If you add the form above to the configuration-yaml file of a theme called "mytheme.yaml", then Typemill will display the configuration-form in the theme-area and store the input-data from the author in the settings-file. The developer can now use the data in the theme like this:

{{ settings.themes.mytheme.myfieldname }}

Meta-Tabs and Public Forms

With the keyword forms you can generate configuration forms for your theme and for your plugin. That is great, but it is not all. Because with plugins, you can also create input forms for meta-tabs of a page or you can even generate public forms like a contact form:

Find more information and examples under metatabs and public forms.

Validation

The input of a user is automatically validated. The backend validation of Typemill is pretty strict and you should always test the input fields intensively. If you run into unwanted validation errors, please report them on GitHub.