Forms define fields and similar components as well as their layout. Form definition is used in dialogs and the detail subapps of content apps.
This form definition is part of the Magnolia 6 UI framework. The fully qualified class name is info.magnolia.ui.editor.FormDefinition
.
If you work with the Magnolia 5 UI framework, see Form definition for Magnolia 5 UI instead.
Example form definition
form: properties: salutation: label: Salutation $type: textField i18n: true firstName: label: First name $type: textField required: true lastName: label: Last name $type: textField required: true email: label: Email $type: textField required: true validators: email: $type: emailValidator phone: label: Phone $type: textField required: true
The properties
list here is defined with the YAML list syntax.
When a property type is defined as a list in the corresponding Java class, you can use the YAML map syntax or list syntax. Map2BeanTransformer converts YAML in both cases correctly.
See YAML: Defining a list property via YAML map or list syntax.
Form properties
properties | required A list of editor property definition items (typically, a list of fields). See Field definition for more information. |
| optional, default is Defines the form layout. The value must be a subtype of See Layout types for more information. |
Layout types
$type | class |
---|---|
|
|
defaultEditorActionLayout | info.magnolia.ui.dialog.layout.DefaultEditorActionLayoutDefinition |
|
|
| info.magnolia.ui.framework.layout.HorizontalLayoutDefinition |
stacked | info.magnolia.ui.framework.layout.StackedLayoutProducer |
|
|
Default layout
With FormLayoutDefinition, it is not possible to configure anything. Use this layout when there is no need for customization.
From Magnolia 6.2.1, FormLayoutDefinition
has replaced the deprecated PlainFormLayoutDefinition
as the default layout.
Tabbed layout
With TabbedLayoutDefinition, you can organize components into tabs.
Horizontal layout
With HorizontalLayoutDefinition, you can arrange components horizontally. To disable spacing between components, set the spacing
property to false
.
Stacked layout
With StackedLayoutProducer, you can arrange components vertically. Any captions are placed above the respective components, which means that more horizontal space is allocated to the components themselves. This is the default layout for composite fields.
Declarative layout
With DeclarativeLayoutDefinition, you can create form entries in an arbitrary Vaadin component container using the Vaadin declarative syntax. Use this layout for full customization.
To render the layout, a template
property is required. Because the Vaadin declarative syntax is used to design custom layouts, the declarative template has to be an HTML document.
In the template, the tag of a component element can have one of the following prefixes:
vaadin-
: Vaadin core component.mgnl-
: Magnolia predefined or user-defined component. To define a mapping between a tag prefix and the Java package of the component, see the "Component Prefix to Package Mapping" section of Designing UIs Declaratively. The following Magnolia predefined components are available:<mgnl-separator/>
: horizontal line to separate content.<mgnl-group caption="">
: group header with acaption
attribute to separate content.
form-
: Magnolia property as defined in YAML.
You can always use Magnolia predefined or user-defined components and Magnolia properties with Vaadin core components.
It is recommended that Magnolia properties be nested inside a <vaadin-form-layout>
tag. If you insert a Magnolia property inside a <vaadin-vertical-layout>
tag, the component will not be rendered as nicely.
If VerticalLayout.java
is stored in src/main/java/info/magnolia/contacts/layout
, my-style.css
should be added to src/main/resources/info/magnolia/contacts/layout
.
Action layout
With DefaultEditorActionLayoutDefinition, you can define an action area in dialogs and the detail subapps of content apps. This is the default layout for footers and includes predefined primary and secondary actions.
To learn about the layout properties, see footerLayout
.