For those manually adding fieldsets and fields to a form panel, ExtJS doesn't require you to add components directly to the form, by doing a getForm() first. It's mainly for convenience, and allows standard functionality to work properly. So whatever component you did the 'add' from, iterate from that component.
Example 1:
Normally you should not use the 'id' to get a component since it's set dynamically. But this shows how you could get the form panel itself using the getCmp.
var formPanel = Ext.getCmp('id-of-component');
var fieldSet = Ext.create('Ext.form.FieldSet', {
title: 'field set'
});
formPanel.add(fieldSet);
When iterating, you would do this:
formPanel.each(function(item) {
alert(item.title);
});
Example 2:
In this example, we add to the actual form itself, so the iteration looks slightly different.
var formPanel = Ext.getCmp('id-of-component');
var fieldSet = Ext.create('Ext.form.FieldSet', {
title: 'field set'
});
formPanel.getForm().add(fieldSet);
When iterating, you would do this:
formPanel.getForm().each(function(item) {
alert(item.title);
});