ContainerLayout AnchorLayout FormLayout
Package: | Ext.layout |
Defined In: | FormLayout.js |
Class: | FormLayout |
Extends: | AnchorLayout |
This layout manager is specifically designed for rendering and managing child Components of forms. It is responsible for rendering the labels of Fields.
This layout manager is used when a Container is configured with the layout:'form' layout config option, and should generally not need to be created directly via the new keyword. See Ext.Container.layout for additional details.
In an application, it will usually be preferrable to use a FormPanel (which is configured with FormLayout as its layout class by default) since it also provides built-in functionality for loading, validating and submitting the form.
A Container using the FormLayout layout manager (e.g. Ext.form.FormPanel or specifying layout:'form') can also accept the following layout-specific config properties:
Any Component (including Fields) managed by FormLayout accepts the following as a config option:
Any Component managed by FormLayout may be rendered as a form field (with an associated label) by configuring it with a non-null fieldLabel. Components configured in this way may be configured with the following options which affect the way the FormLayout renders them:
Example usage:
// Required if showing validation messages
Ext.QuickTips.init();
// While you can create a basic Panel with layout:'form', practically
// you should usually use a FormPanel to also get its form functionality
// since it already creates a FormLayout internally.
var form = new Ext.form.FormPanel({
title: 'Form Layout',
bodyStyle: 'padding:15px',
width: 350,
defaultType: 'textfield',
defaults: {
// applied to each contained item
width: 230,
msgTarget: 'side'
},
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false,
labelSeparator: ':' // override labelSeparator layout config
},{
fieldLabel: 'Last Name',
name: 'last'
},{
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}, {
xtype: 'textarea',
hideLabel: true, // override hideLabels layout config
name: 'msg',
anchor: '100% -53'
}
],
buttons: [
{text: 'Save'},
{text: 'Cancel'}
],
layoutConfig: {
labelSeparator: '~' // superseded by assignment below
},
// config options applicable to container when layout='form':
hideLabels: false,
labelAlign: 'left', // or 'right' or 'top'
labelSeparator: '>>', // takes precedence over layoutConfig value
labelWidth: 65, // defaults to 100
labelPad: 8 // defaults to 5, must specify labelWidth to be honored
});
Config Options | Defined By | |
---|---|---|
anchor : String This configuation option is to be applied to child items of a container managed by
this layout (ie. configured with l... This configuation option is to be applied to child items of a container managed by this layout (ie. configured with layout:'anchor'). This value is what tells the layout how an item should be anchored to the container. items added to an AnchorLayout accept an anchoring-specific config property of anchor which is a string containing two values: the horizontal anchor value and the vertical anchor value (for example, '100% 50%'). The following types of anchor values are supported:
| AnchorLayout | |
defaultAnchor : String default anchor for all child container items applied if no anchor or specific width is set on the child item. Defaul... default anchor for all child container items applied if no anchor or specific width is set on the child item. Defaults to '100%'. | AnchorLayout | |
extraCls : String An optional extra CSS class that will be added to the container. This can be useful for adding
customized styles to t... An optional extra CSS class that will be added to the container. This can be useful for adding customized styles to the container or any of its children using standard CSS rules. See Ext.Component.ctCls also. Note: extraCls defaults to '' except for the following classes which assign a value by default:
| ContainerLayout | |
fieldTpl : Ext.Template A compiled Ext.Template for rendering
the fully wrapped, labeled and styled form Field. Defaults to:new Ext.Template(... A compiled Ext.Template for rendering
the fully wrapped, labeled and styled form Field. Defaults to:
This may be specified to produce a different DOM structure when rendering form Fields. A description of the properties within the template follows:
Also see getTemplateArgs | FormLayout | |
labelSeparator : String See Ext.form.FormPanel.labelSeparator. Configuration
of this property at the container level takes precedence. | FormLayout | |
renderHidden : Boolean True to hide each contained item on render (defaults to false). | ContainerLayout | |
trackLabels : Boolean True to show/hide the field label when the field is hidden. Defaults to false. | FormLayout |
Property | Defined By | |
---|---|---|
fieldTpl : Ext.Template The Ext.Template used by Field rendering layout classes (such as
Ext.layout.FormLayout) to create the DOM structure o... The Ext.Template used by Field rendering layout classes (such as
Ext.layout.FormLayout) to create the DOM structure of a fully wrapped,
labeled and styled form Field. A default Template is supplied, but this may be
overriden to create custom field structures. The template processes values returned from
Ext.layout.FormLayout.getTemplateArgs. | ContainerLayout | |
if : Object This monitorResize flag will be renamed soon as to avoid confusion
with the Container version which hooks onWindowRes... This monitorResize flag will be renamed soon as to avoid confusion
with the Container version which hooks onWindowResize to doLayout
monitorResize flag in this context attaches the resize event between
a container and it's layout | ContainerLayout | |
labelStyle : String Read only. The CSS style specification string added to field labels in this layout if not
otherwise specified by each... Read only. The CSS style specification string added to field labels in this layout if not
otherwise specified by each contained field. | FormLayout |
Method | Defined By | |
---|---|---|
getTemplateArgs( (Ext.form.Field field )
:
ObjectProvides template arguments for rendering the fully wrapped, labeled and styled form Field.
This method returns an ob... Provides template arguments for rendering the fully wrapped, labeled and styled form Field. This method returns an object hash containing properties used by the layout's fieldTpl to create a correctly wrapped, labeled and styled form Field. This may be overriden to create custom layouts. The properties which must be returned are:
Parameters:
| FormLayout | |
parseMargins( Number|String v )
:
ObjectParses a number or string representing margin sizes into an object. Supports CSS-style margin declarations
(e.g. 10, ... Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations
(e.g. 10, "10", "10 10", "10 10 10" and "10 10 10 10" are all valid options and would return the same result) Parameters:
| ContainerLayout |