How to dynamically add a hidden field to a form in Sencha Ext JS 4

This code shows how to dynamically add a hidden field to a form with Sencha ExtJS 4:

createHiddenField: function(projectName) {
    return Ext.form.Field({
        xtype: 'hiddenfield',
        name: 'projectId',
        value: this.getProjectId(projectName)
        // autoCreate : {type: 'hidden', id: 'partID', name: 'partID', value:'', width: 0}
    });
}

I saw the autoCreate code on a Sencha forum, but that doesn't seem to be necessary; the code works as shown.

 

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.