View Full Version : How to exclude a container from basicform getFieldValues()

10 Jan 2012, 6:45 AM

I have a formpanel with some child containers which hold some fields. When I call the getFieldValues() function an object with all fields and their values will be returned. I want some of containers will be excluded from getFieldValues(). I can't find a config setting, I'm using Ext 4.1 beta.

Is this possible?


10 Jan 2012, 7:59 AM
What do you mean container? Only components with isFormField set to true will be polled for a value. And then it has to have some other methods that only fields have like isValid

11 Jan 2012, 10:18 PM
I will try to explain it with an example (see also add screenshot).

I have a form in which I can manage a resource for a scheduling system. I can manage data like firstname, lastname, address, etc. In the same form panel there is a grid which holds data for the applied shifts. On the right side of that grid I can mange the selected shift. I use the getFieldValues() from the shift panel to apply modifications to the grid's store.

When I want to save the resource I call the getFieldValues() method. But I donīt want the shift fields to be included. How to ignore the shift panel fields for the getFieldValues() for the whole form?

12 Jan 2012, 5:55 AM
set isFormField to false on the fields you don't want to include and that will exclude it from any of the methods that get values.

12 Jan 2012, 6:00 AM

Ext 4's Basic Form has a hidden 'nugget' that you could take advantage of:

getFields: function() {
var fields = this._fields;
if (!fields) {
fields = this._fields = Ext.create('Ext.util.MixedCollection');
return fields;

Before your call to getFieldValues, create a new _fields cache collection based on filter criteria you may be more familiar with:

var basic = myForm.getForm(),
fields = Ext.create('Ext.util.MixedCollection'),

fields.addAll(myForm.query('field:submitValue')); //or other criteria
basic._fields = fields;
values = basic.getFieldValues(); //Now call it!

And, in any container you want to exclude from consideration just add:

defaults : {submitValue : false }

13 Jan 2012, 12:02 AM
Thanks for the hidden 'nugget' and the example code. It's working now!