X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/form/field/Hidden.js?ds=sidebyside diff --git a/src/form/field/Hidden.js b/src/form/field/Hidden.js new file mode 100644 index 00000000..5aaa68ae --- /dev/null +++ b/src/form/field/Hidden.js @@ -0,0 +1,68 @@ +/** + * @class Ext.form.field.Hidden + * @extends Ext.form.field.Base + *

A basic hidden field for storing hidden values in forms that need to be passed in the form submit.

+ *

This creates an actual input element with type="submit" in the DOM. While its label is + * {@link #hideLabel not rendered} by default, it is still a real component and may be sized according to + * its owner container's layout.

+ *

Because of this, in most cases it is more convenient and less problematic to simply + * {@link Ext.form.action.Action#params pass hidden parameters} directly when + * {@link Ext.form.Basic#submit submitting the form}.

+ *

Example:

+ *
new Ext.form.Panel({
+    title: 'My Form',
+    items: [{
+        xtype: 'textfield',
+        fieldLabel: 'Text Field',
+        name: 'text_field',
+        value: 'value from text field'
+    }, {
+        xtype: 'hiddenfield',
+        name: 'hidden_field_1',
+        value: 'value from hidden field'
+    }],
+
+    buttons: [{
+        text: 'Submit',
+        handler: function() {
+            this.up('form').getForm().submit({
+                params: {
+                    hidden_field_2: 'value from submit call'
+                }
+            });
+        }
+    }]
+});
+ *

Submitting the above form will result in three values sent to the server: + * text_field=value+from+text+field&hidden_field_1=value+from+hidden+field&
hidden_field_2=value+from+submit+call

+ * + * @constructor + * Create a new Hidden field. + * @param {Object} config Configuration options + * + * @xtype hiddenfield + */ +Ext.define('Ext.form.field.Hidden', { + extend:'Ext.form.field.Base', + alias: ['widget.hiddenfield', 'widget.hidden'], + alternateClassName: 'Ext.form.Hidden', + + // private + inputType : 'hidden', + hideLabel: true, + + initComponent: function(){ + this.formItemCls += '-hidden'; + this.callParent(); + }, + + // These are all private overrides + initEvents: Ext.emptyFn, + setSize : Ext.emptyFn, + setWidth : Ext.emptyFn, + setHeight : Ext.emptyFn, + setPosition : Ext.emptyFn, + setPagePosition : Ext.emptyFn, + markInvalid : Ext.emptyFn, + clearInvalid : Ext.emptyFn +});