Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

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.

Table of Contents

Example

...

definition

Code Block
languageyml
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.

...

Form properties

properties

required

A list List of editor property definition items (typically, a list of fields).

See Field definition for more information.

layout

optional, default is info.magnolia.ui.framework.layout.FormLayoutDefinition

Defines the form layout. The value must be a subtype of info.magnolia.ui.framework.layout.LayoutDefinition.

See Form layout Layout types for more information.

Layout types

$typeclass

declarativeLayout

info.magnolia.ui.framework.layout.DeclarativeLayoutDefinition

defaultEditorActionLayoutinfo.magnolia.ui.dialog.layout.DefaultEditorActionLayoutDefinition

form

info.magnolia.ui.framework.layout.

Available field definition classes

...

FormLayoutDefinition

horizontal

info.magnolia.ui.framework.layout.HorizontalLayoutDefinition
stackedinfo.magnolia.ui.framework.layout.StackedLayoutProducer

tabbedLayout

info.magnolia.ui.framework.layout.TabbedLayoutDefinition

Default layout

With

Javadoc resource link
classNameinfo.magnolia.ui.framework.layout.FormLayoutDefinition
renderTypeasynchronous

...

Form layout

Default layout

With the default layout, it is not possible to configure anything. Use this layout class when there is no need for customization.

Use info.magnolia.ui.framework.layout.FormLayoutDefinition for the class property or form for the $type shortcut.

...

(info) From Magnolia 6.2.1, FormLayoutDefinition has replaced the deprecated PlainFormLayoutDefinition as the default layout.

...

Tabbed layout

With the horizontal layout, you can enable spacing between fields in the layout.Use 

Javadoc resource link
className
info.magnolia.ui.framework.layout.
HorizontalLayoutDefinition for the class property or horizontal for the $type shortcut
TabbedLayoutDefinition
renderTypeasynchronous
, you can organize components into tabs.

Code Block
languageyml
titleExample horizontal tabbed layout definition
collapsetrue
compositelayout:
  $type: compositeFieldtabbedLayout
  labeltabs: Name
  layout: horizontal
  fieldspersonal:
    -  namefields: salutation
      label: Salutation
  - name: salutation
  $type: select
     - optionsname: firstName
        - name: Mr.lastName
    details:
      valuefields: Mr.
        -  labelname: Mr.email
        - name: Mrs.phone

Horizontal layout

With

Javadoc resource link
classNameinfo.magnolia.ui.framework.layout.HorizontalLayoutDefinition
renderTypeasynchronous
, you can arrange components horizontally. To disable spacing between components, set the spacing property to false.

Code Block
languageyml
titleExample horizontal layout definition
collapsetrue
layout:
  $type: horizontal
  fields:
    - valuename: Mrs.salutation
      $type: textField
      label: Mrs.Salutation
    - name: firstName
      $type: texttextField
      label: First name
    - name: lastName
      $type: texttextField
      label: Last name

...

Stacked layout

With the tabbed layout, you can add or remove tabs and fields. It is not possible to change how any tabs and fields are rendered.Use 

Javadoc resource link
className
info.magnolia.ui.framework.layout
.TabbedLayoutDefinition for the class property or tabbedLayout for the $type shortcut
.StackedLayoutProducer
renderTypeasynchronous
, 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.

Code Block
languageyml
titleExample tabbed stacked layout definition
collapsetrue
layout:
  $type: tabbedLayoutstacked
  tabs:
    personal:
      fields:
        - name: salutation
        - name$type: firstNametextField
        - namelabel: lastNameSalutation
    details:
      fields:
        - name: emailfirstName
        - name$type: phone
    address:textField
      fieldslabel:
        - First name: streetAddress
        - name: postalCodelastName
        - name$type: citytextField
      label:  -Last name: country

Declarative layout

With the declarative layout

Javadoc resource link
classNameinfo.magnolia.ui.framework.layout.DeclarativeLayoutDefinition
renderTypeasynchronous
, you can create form entries in an arbitrary Vaadin component container using the Vaadin declarative syntax. Use this layout class for full customization.

Use info.magnolia.ui.framework.layout.DeclarativeLayoutDefinition for the class property or declarativeLayout for the $type shortcut.

Code Block
languageyml
titleExample declarative layout definition
collapsetrue
layout:
  $type: declarativeLayout
  template: /contacts/layouts/edit-contact.html

...

Info

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

Javadoc resource link
classNameinfo.magnolia.ui.dialog.layout.DefaultEditorActionLayoutDefinition
renderTypeasynchronous
, you can define an action area in both 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.