]>
git.proxmox.com Git - extjs.git/blob - extjs/modern/modern/src/form/FieldSet.js
2 * A FieldSet is a great way to visually separate elements of a form. It's normally used when you have a form with
3 * fields that can be divided into groups - for example a customer's billing details in one fieldset and their shipping
4 * address in another. A fieldset can be used inside a form or on its own elsewhere in your app. Fieldsets can
5 * optionally have a title at the top and instructions at the bottom. Here's how we might create a FieldSet inside a
9 * Ext.create('Ext.form.Panel', {
15 * instructions: 'Tell us all about yourself',
32 * Above we created a {@link Ext.form.Panel form} with a fieldset that contains two text fields. In this case, all
33 * of the form fields are in the same fieldset, but for longer forms we may choose to use multiple fieldsets. We also
34 * configured a {@link #title} and {@link #instructions} to give the user more information on filling out the form if
37 Ext
.define('Ext.form.FieldSet', {
38 extend
: 'Ext.Container',
39 alias
: 'widget.fieldset',
40 requires
: ['Ext.Title'],
47 baseCls
: Ext
.baseCSSPrefix
+ 'form-fieldset',
51 * Optional fieldset title, rendered just above the grouped fields.
55 * Ext.create('Ext.form.Fieldset', {
71 * @cfg {String} instructions
72 * Optional fieldset instructions, rendered just below the grouped fields.
76 * Ext.create('Ext.form.Fieldset', {
79 * instructions: 'Please enter your email address.',
95 applyTitle: function(title
) {
96 if (typeof title
== 'string') {
97 title
= {title
: title
};
102 baseCls
: this.getBaseCls() + '-title'
105 return Ext
.factory(title
, Ext
.Title
, this._title
);
111 updateTitle: function(newTitle
, oldTitle
) {
116 this.remove(oldTitle
);
123 getTitle: function() {
124 var title
= this._title
;
126 if (title
&& title
instanceof Ext
.Title
) {
127 return title
.getTitle();
136 applyInstructions: function(instructions
) {
137 if (typeof instructions
== 'string') {
138 instructions
= {title
: instructions
};
141 Ext
.applyIf(instructions
, {
143 baseCls
: this.getBaseCls() + '-instructions'
146 return Ext
.factory(instructions
, Ext
.Title
, this._instructions
);
152 updateInstructions: function(newInstructions
, oldInstructions
) {
153 if (newInstructions
) {
154 this.add(newInstructions
);
156 if (oldInstructions
) {
157 this.remove(oldInstructions
);
164 getInstructions: function() {
165 var instructions
= this._instructions
;
167 if (instructions
&& instructions
instanceof Ext
.Title
) {
168 return instructions
.getTitle();
175 * A convenient method to disable all fields in this FieldSet
176 * @return {Ext.form.FieldSet} This FieldSet
179 updateDisabled: function(newDisabled
) {
180 this.getFieldsAsArray().forEach(function(field
) {
181 field
.setDisabled(newDisabled
);
190 getFieldsAsArray: function() {
192 getFieldsFrom = function(item
) {
197 if (item
.isContainer
) {
198 item
.getItems().each(getFieldsFrom
);
202 this.getItems().each(getFieldsFrom
);