//Ext2.2的Ext.form.FormPanel中如果有RadioGroup或者CheckboxGroup，那麼FormPanel.form.setValues方法對這2個東東內部的radio和checkbox無法動態賦值
Ext.override(Ext.form.CheckboxGroup, {
  getNames: function() {
    var n = [];

    this.items.each(function(item) {
      if (item.getValue()) {
        n.push(item.getName());
      }
    });

    return n;
  },

  getValues: function() {
    var v = [];

    this.items.each(function(item) {
      if (item.getValue()) {
        v.push(item.getRawValue());
      }
    });

    return v;
  },

  setValues: function(v) {
    var r = new RegExp('(' + v.join('|') + ')');

    this.items.each(function(item) {
      item.setValue(r.test(item.getRawValue()));
    });
  }
});

Ext.override(Ext.form.RadioGroup, {
  getName: function() {
    return this.items.first().getName();
  },

  getValue: function() {
    var v;

    this.items.each(function(item) {
      v = item.getRawValue();
      return !item.getValue();
    });

    return v;
  },

  setValue: function(v) {
    this.items.each(function(item) {
      item.setValue(item.getRawValue() == v);
    });
  }
});


 /*  
    //在Ext2.2的Ext.form.FormPanel中如果有RadioGroup或者CheckboxGroup，那麼FormPanel.form.setValues方法對這2個東東內部的radio和checkbox無法動態賦值，需要對Ext.form.BasicForm的findField方法進行修正，代碼如下：
	Ext.override(Ext.form.BasicForm,{  
	    findField : function(id){          
	        var field = this.items.get(id);          
	        if(!field){  
	            this.items.each(function(f){  
	                if(f.isXType('radiogroup')||f.isXType('checkboxgroup')){  
	                    f.items.each(function(c){  
	                        if(c.isFormField && (c.dataIndex == id || c.id == id || c.getName() == id)){  
	                            field = c;  
	                            return false;  
	                        }  
	                    });  
	                }  
	                                  
	                if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){  
	                    field = f;  
	                    return false;  
	                }  
	            });  
	        }  
	        return field || null;  
	    }   
	});     
*/   
