Usage
Signature:
interface FormLayoutElement
Typescript Import Format
//To typecheck the element APIs, import as below.
import { FormLayoutElement } from "ojs/ojformlayout";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojformlayout";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Styling Classes
-
.oj-formlayout-full-width
-
In Redwood by default a form layout has a max width, add this class if you'd like to opt out and have the form layout to stretch the full width.
Example
<oj-form-layout class="oj-formlayout-full-width"> </oj-form-layout>
-
CSS Variables
Name | Type | Description |
---|---|---|
--oj-form-layout-margin-bottom |
<length> | Bottom margin of each row in a form layout |
--oj-form-layout-column-min-width |
<length> | Form layout column min width |
--oj-form-layout-column-max-width |
<length> | Form layout column max width |
--oj-form-layout-start-edge-column-min-width |
<length> | Form layout column min width when label-edge is set to start |
--oj-form-layout-start-edge-column-max-width |
<length> | Form layout column max width when label-edge is set to start |
--oj-form-layout-column-gutter |
<length> | Gutter between form layout columns |
--oj-form-layout-top-edge-label-to-value-padding |
<length> | Vertical padding between the label and value when label-edge is set to top in a form layout |
--oj-form-layout-start-edge-label-text-align |
start | end | Label text align when label-edge is set to start in a form layout |
--oj-form-layout-start-edge-value-text-align |
start | end | Value text align when label-edge is set to start in a form layout |
--oj-form-layout-start-edge-label-to-value-padding |
<length> | Horizontal padding between the label and value when label-edge is set to start in a form layout |
--oj-form-layout-horizontal-margin |
<length> | Form layout horizontal margin |
--oj-form-layout-divider-width |
<length> | Form layout divider width |
--oj-form-layout-divider-margin |
<length> | Form layout divider margin |
Slots
JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.
-
Default
-
The
<oj-form-layout>
element only accepts element children in the Default slot. Content in<oj-form-layout>
's Default slot will be laid out in a row/column style form layout.- Since:
- 4.1.0
Attributes
-
colspan-wrap :"nowrap"|"wrap"
-
Specifies how to fit components with colspan attribute in the form layout, when there are fewer columns left in the current row than the colspan value specifies.
The default value depends on the theme.
Supported Values:
Value Description nowrap
The component will occupy the remaining columns in the current row. wrap
The component will start from the first column of the next row. Names
Item Name Property colspanWrap
Property change event colspanWrapChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-colspan-wrap-changed
-
columns :number
-
Specifies the absolute number of columns and overrides max-columns, if the value is positive. If the value is not positive, then this attribute is ignored and max-columns is used to determine the number of columns. This attribute should only be used in special circumstances where you need a specific number of columns even if the fields will be narrower than the suggested minimum (a nested form layout might be an example).
- Default Value:
0
Names
Item Name Property columns
Property change event columnsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-columns-changed
-
direction :"column"|"row"
-
Specifies the layout direction of the form layout children.
The default value depends on the theme.
Supported Values:
Value Description column
Components are laid out in columns row
Components are laid out in rows Names
Item Name Property direction
Property change event directionChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-direction-changed
-
label-edge :"inside"|"start"|"top"
-
Specifies how the label is created and aligned with its form control.
The default value varies by theme, and it works well for the theme in most cases. The oj-form-layout component uses the MetadataTypes.PropertyBinding
provide
property to provide itslabel-edge
attribute to any descendent form components and oj-form-layout. It also uses MetadataTypes.ProvidePropertytransform
property to transform thelabel-edge
attribute to its descendent form components. The form components and the oj-form-layout are configured to consume the label-edge property if it is not explicitly set. For example, if the oj-form-layout's label-edge attribute is set to "top" or "start", and a descendent form component does not have its label-edge attribute set, the form component's label-edge will be the transformed value "provided".When using the oj-form-layout custom element inside of a VDOM application, this property will not propagate down to the child components. This is because binding propagation is Knockout-based, and VDOM applications are not Knockout-based.
Supported Values:
Value Description inside
oj-form-layout will not create any label. Label will be created by the form control if the form control has its label-edge set to "inside". Please see the specific form control's label-edge attribute documentation for details. start
oj-form-layout will create a label that's before the start of the form control if the form control's label-edge is not explicitly set. If the form control specifies "inside" or "none" as its label-edge, no label will be created by oj-form-layout. top
oj-form-layout will create a label that's on top of the form control if the form control‘s label-edge is not explicitly set. If the form control specifies "inside" or "none" as its label-edge, no label will be created by oj-form-layout. Names
Item Name Property labelEdge
Property change event labelEdgeChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-edge-changed
-
label-width :string
-
Specifies the label width.
This specifies the width of the oj-label elements. This can be any legal CSS width.
When using the oj-form-layout custom element inside of a VDOM application, this property will not propagate down to the child components. This is because binding propagation is Knockout-based, and VDOM applications are not Knockout-based.
- Default Value:
"33%"
Names
Item Name Property labelWidth
Property change event labelWidthChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-width-changed
-
label-wrapping :"truncate"|"wrap"
-
Specifies if the label text should wrap or truncate.
When using the oj-form-layout custom element inside of a VDOM application, this property will not propagate down to the child components. This is because binding propagation is Knockout-based, and VDOM applications are not Knockout-based.
- Default Value:
"wrap"
Supported Values:
Value Description truncate
Label will truncate if needed wrap
Label will wrap if needed Names
Item Name Property labelWrapping
Property change event labelWrappingChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-wrapping-changed
-
max-columns :number
-
Specifies the maximum number of columns. The actual number of columns will be responsively determined based on the viewport size and the column width specified in the theme. Note that max-columns will be ignored if columns has a positive value.
- Default Value:
1
Names
Item Name Property maxColumns
Property change event maxColumnsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-max-columns-changed
-
readonly :boolean
-
Specifies whether the form is readonly. A readonly form has no reserved rows for user assistance text.
The oj-form-layout component uses the MetadataTypes.PropertyBinding
provide
property to provide itsreadonly
property to any descendent components that are configured to consume it. The form components and the oj-form-layout are configured to consume the readonly property if it is not explicitly set. For example, if the oj-form-layout's readonly attribute is set to true, and a descendent form component does not have its readonly attribute set, the form component's readonly will be true.When using the oj-form-layout custom element inside of a VDOM application, this property will not propagate down to the child components. This is because binding propagation is Knockout-based, and VDOM applications are not Knockout-based.
- Default Value:
false
Names
Item Name Property readonly
Property change event readonlyChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-readonly-changed
-
user-assistance-density :('reflow'|'efficient'|'compact')
-
Note: This attribute is not supported in the following themes:
Alta
-
Specifies the density of the form layout's user assistance presentation. It can be shown inline with reserved rows to prevent reflow if a user assistance text shows up, inline without reserved rows, or it can be shown compactly in a popup instead.
The oj-form-layout component uses the MetadataTypes.PropertyBinding
provide
property to provide its user-assistance-density property to any descendent components that are configured to consume it. The form components and the oj-form-layout are configured to consume the user-assistance-density property if it is not explicitly set. For example, oj-form-layout's user-assistance-density defaults to 'efficient', so all its oj-form-layout and form control descendants will have user-assistance-density='efficient' by default.When using the oj-form-layout custom element inside of a VDOM application, this property will not propagate down to the child components. This is because binding propagation is Knockout-based, and VDOM applications are not Knockout-based.
- Default Value:
"efficient"
Supported Values:
Value Description compact
messages, help, hints, and required will not be shown inline; they will show in a mode that keeps the screen more compact, like a popup for the messages, and a required icon to indicate Required. efficient
messages, help, hints, and required are all shown inline under the field with reserved space underneath. reflow
If reflow, messages, help, hints, and required are all shown inline under the field with no reserved space. Names
Item Name Property userAssistanceDensity
Property change event userAssistanceDensityChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-user-assistance-density-changed
Methods
-
getProperty(property) : {any}
-
Retrieves a value for a property or a single subproperty for complex properties.
Parameters:
Name Type Description property
string The property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
-
refresh : {void}
-
Refreshes the visual state of the component.
Returns:
- Type
- void
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description properties
Object An object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
Parameters:
Name Type Description property
string The property name to set. Supports dot notation for subproperty access. value
any The new value to set the property to. Returns:
- Type
- void