1.5 ViewHelper usage

Flux has both a PHP and ViewHelper API (in fact, the ViewHelper API is a shell for the PHP API). The side used most frequently is the ViewHelper side, which you use from inside your templates. These ViewHelpers use a combination of nesting and arguments to configure how your form fields should appear. To give you an example, in Flux terms an Object is a set of Fields which belong together - but the same ViewHelpers which make the Fields inside Objects are used to make Fields inside a Sheet and a Container:

<!-- Inside an object... -->
<flux:form.section name="objects">
    <flux:form.object name="object">
        <flux:field.input name="myfield" />
    </flux:form.object>
</flux:form.section>
<!-- ...and outside -->
<flux:form.field.input name="settings.myfield" />

The example above would generate variables containing an array with any number of "objects" which can be inserted by the content editor, each one is an "object" with one "field" called myfield, because the flux:field was used inside an object inside a section. The last field adds a field in the root level called settings.myfield - because this field is not nested inside an Object or Container etc.

The rules are:

  • <flux:form /> and <flux:grid /> are only allowed on the root level of your templateĀ“s Configuration section.
  • <flux:grid.row /> is allowed inside <flux:grid />.
  • <flux:grid.column /> is allowed inside <flux:grid.row />.
  • <flux:form.sheet /> can be used only inside <flux:form />.
  • <flux:field.* /> is possible in <flux:form.container />, <flux:form.object /> and <flux:form.sheet />.
  • <flux:wizard /> is possible inside <flux:field.* /> only.

Rendering Assistance ViewHelpers

Both Flux and VHS contain ViewHelpers to render content elements - Flux contains those which render content elements nested inside Flux-enabled plugins/content, whereas VHS renders content elements in the same way traditional content rendering would (e.g. by value of colPos) and ignores elements nested in other elements.

As a rule of thumb you use VHS content rendering ViewHelpers in page templates and Flux content rendering ViewHelpers in content templates.

Continue: Chapter 1.6: Fluid - best practices.

Jump to...