class sap.ui.layout.form.FormElement

Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/layout/form/FormElement
Application Component: CA-UI5-CMP

A FormElement represents a row in a FormContainer. A FormElement is a combination of one label and different controls associated to this label.


Constructor

Constructor for a new sap.ui.layout.form.FormElement.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.

new sap.ui.layout.form.FormElement(sId?, mSettings?)
Param Type Default Value Description
sId? string

ID for the new control, generated automatically if no ID is given

mSettings? object

Initial settings for the new control


Properties

Name Type Default Value Description
_editable boolean false

Internal property for the editable state of the internal FormElement.

Visibility: hidden
visible boolean true

If set to false, the FormElement is not rendered.

Visibility: public

Aggregations

Default Aggregation: fields

Name Cardinality Type Description
_label 0..1 sap.ui.core.Label
fields (default) 0..n sap.ui.core.Control

Form controls that belong together to be displayed in one row of a Form.

Warning: Do not put any layout or other container controls in here. This could damage the visual layout, keyboard support and screen-reader support. Only form controls are allowed. Views are also not supported. Allowed controls implement the interface sap.ui.core.IFormContent.

label 0..1 sap.ui.core.Label

Label of the fields. Can either be a Label control or a string. If a Label control is used, the properties of the Label can be set. If no assignment between Label and the fields is set via (labelFor property of the Label), it will be done automatically by the FormElement. In this case the Label is assigned to the fields of the FormElement.


Methods Overview

Method Description
_setEditable

Sets the editable state of the FormElement.

This must only be called from the Form and it's FormContainers.

Labels inside of a Form must be invalidated if editable changed on Form.

addField

Adds some field to the aggregation fields.

destroyFields

Destroys all the fields in the aggregation fields.

destroyLabel

Destroys the label in the aggregation label.

sap.ui.layout.form.FormElement.extend

Creates a new subclass of class sap.ui.layout.form.FormElement with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Element.extend.

getFields

Gets content of aggregation fields.

Form controls that belong together to be displayed in one row of a Form.

Warning: Do not put any layout or other container controls in here. This could damage the visual layout, keyboard support and screen-reader support. Only form controls are allowed. Views are also not supported. Allowed controls implement the interface sap.ui.core.IFormContent.

getFieldsForRendering

Determines what fields must be rendered.

getLabel

Gets content of aggregation label.

Label of the fields. Can either be a Label control or a string. If a Label control is used, the properties of the Label can be set. If no assignment between Label and the fields is set via (labelFor property of the Label), it will be done automatically by the FormElement. In this case the Label is assigned to the fields of the FormElement.

getLabelControl

Returns the Label of the FormElement, even if the Label is assigned as string. The FormLayout needs the information of the label to render the Form.

sap.ui.layout.form.FormElement.getMetadata

Returns a metadata object for class sap.ui.layout.form.FormElement.

getVisible

Gets current value of property visible.

If set to false, the FormElement is not rendered.

Default value is true.

indexOfField

Checks for the provided sap.ui.core.Control in the aggregation fields. and returns its index if found or -1 otherwise.

insertField

Inserts a field into the aggregation fields.

invalidateLabel

Labels inside of a Form must be invalidated if "editable" changed on Form

isVisible

Determines if the FormElement is visible or not. Per default it just returns the value of the visible property. But this might be overwritten by inherited elements.

For rendering by FormLayouts this function has to be used instead of getVisible.

removeAllFields

Removes all the controls from the aggregation fields.

Additionally, it unregisters them from the hosting UIArea.

removeField

Removes a field from the aggregation fields.

setLabel

Sets the aggregated label.

setVisible

Sets a new value for property visible.

If set to false, the FormElement is not rendered.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

_setEditable

Sets the editable state of the FormElement.

This must only be called from the Form and it's FormContainers.

Labels inside of a Form must be invalidated if editable changed on Form.

Param Type DefaultValue Description
bEditable boolean

Editable state of the Form

addField

Adds some field to the aggregation fields.

Param Type DefaultValue Description
oField sap.ui.core.Control

The field to add; if empty, nothing is inserted

destroyFields

Destroys all the fields in the aggregation fields.

destroyLabel

Destroys the label in the aggregation label.

sap.ui.layout.form.FormElement.extend

Creates a new subclass of class sap.ui.layout.form.FormElement with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Element.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

getFields

Gets content of aggregation fields.

Form controls that belong together to be displayed in one row of a Form.

Warning: Do not put any layout or other container controls in here. This could damage the visual layout, keyboard support and screen-reader support. Only form controls are allowed. Views are also not supported. Allowed controls implement the interface sap.ui.core.IFormContent.

getFieldsForRendering

Determines what fields must be rendered.

getLabel

Gets content of aggregation label.

Label of the fields. Can either be a Label control or a string. If a Label control is used, the properties of the Label can be set. If no assignment between Label and the fields is set via (labelFor property of the Label), it will be done automatically by the FormElement. In this case the Label is assigned to the fields of the FormElement.

getLabelControl

Returns the Label of the FormElement, even if the Label is assigned as string. The FormLayout needs the information of the label to render the Form.

sap.ui.layout.form.FormElement.getMetadata

Returns a metadata object for class sap.ui.layout.form.FormElement.

getVisible

Gets current value of property visible.

If set to false, the FormElement is not rendered.

Default value is true.

indexOfField

Checks for the provided sap.ui.core.Control in the aggregation fields. and returns its index if found or -1 otherwise.

Param Type DefaultValue Description
oField sap.ui.core.Control

The field whose index is looked for

insertField

Inserts a field into the aggregation fields.

Param Type DefaultValue Description
oField sap.ui.core.Control

The field to insert; if empty, nothing is inserted

iIndex int

The 0-based index the field should be inserted at; for a negative value of iIndex, the field is inserted at position 0; for a value greater than the current size of the aggregation, the field is inserted at the last position

invalidateLabel

Labels inside of a Form must be invalidated if "editable" changed on Form

isVisible

Determines if the FormElement is visible or not. Per default it just returns the value of the visible property. But this might be overwritten by inherited elements.

For rendering by FormLayouts this function has to be used instead of getVisible.

removeAllFields

Removes all the controls from the aggregation fields.

Additionally, it unregisters them from the hosting UIArea.

removeField

Removes a field from the aggregation fields.

Param Type DefaultValue Description
vField int string sap.ui.core.Control

The field to remove or its index or id

setLabel

Sets the aggregated label.

Param Type DefaultValue Description
vLabel sap.ui.core.Label string

The label to set

setVisible

Sets a new value for property visible.

If set to false, the FormElement is not rendered.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Param Type DefaultValue Description
bVisible boolean true

New value for property visible