1.2 Flux usage
Flux is (among other things) a way to let you define form fields (aka. flexform fields) inside your Fluid template. Fluid Powered TYPO3 uses this behavior in every templating feature - your content elements' templates can for example add form fields which the content editor fills out and you finally render in the template view. This makes it very easy for you to add those special options your editors will need - toggles for how to display the content, selection of target pages for links, and much more.
When you are ready to move on to more advanced forms and fields, Flux also has a full-featured PHP context in which you can build customized and reusable forms with little effort.
Forms for records
By using Flux to generate our form fields which we use to edit a record's properties, we gain a number of benefits:
- Each field and object type (for example sheets) is represented by both a ViewHelper and a PHP class and you can use either one, or both simultaneously. The result is the same.
- Your structure is validated with clear error messages about missing required attributes, incorrect values, bad field types and more.
- Your forms and fields can be shared among many templates (same as flexforms could) but you can still add to and manipulate the form's structure in each template. Every component you use is reusable and can be configured for just the right result.
The main power of Flux in this context is that it provides the (fairly complex) base feature set that is useful in almost all types of extensions - especially those which use form fields to let content editors configure each element.
Providers for records
Another of Flux's main tricks is the association of a special
Provider class type. A
Provider is in the simplest possible terms, a class which has methods that receive one record and process it or return variables based on properties of the record. For example, a
Provider has a
getTemplatePathAndFilename method which accepts the
$row - extensions like
fluidcontent use this in order to return different template filenames depending on the value of the "Fluid Content Type" field. Needless to say this is a limited description of what a
Provider can actually do - and you can study the chapters of this documentation which deal specifically with
Providers to learn more.
Continue: Chapter 1.3: Template file usage.