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
Objects are used to make
Fields inside a
Sheet and a
<!-- 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
The rules are:
<flux:grid />are only allowed on the root level of your template´s Configuration section.
<flux:grid.row />is allowed inside
<flux:grid.column />is allowed inside
<flux:form.sheet />can be used only inside
<flux:field.* />is possible in
<flux:wizard />is possible inside
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.