Ext.ns('ES');

ES.ElectricityCounter_Form = Ext.extend(Ext.FormPanel,{
  frame:true,
  border:true,
  labelWidth:100,
  height:210,
  autoload:null
  ,buttons: [{text: 'Sauver'}]
  ,initComponent:function() {
    var config = {
      layout:'form'
      ,buttonAlign:'right'
      ,frame:false
      ,border:true
      ,bodyStyle:'padding:10px'
      ,items:[{
        title:'Compteur electricité : '
        ,layout:'form'
        ,xtype:'fieldset'
        ,border:false
        ,autoHeight:true
        ,defaultType:'textfield'
        ,bodyStyle:'padding:4px'
        ,items:[{
          name:'tree_node_id'
          ,fieldLabel:'Tree Node id'
          ,hidden: true
          ,hideLabel: true
        },{
          xtype:'TextField1'
          ,name:'electricitycountername'
          ,fieldLabel:'Nom du compteur electricité'
          ,allowBlank:false
        },{
          xtype: 'radio',
          checked: true,
          fieldLabel: 'Type de tarif',
          id:'simpleRadio',
          boxLabel: 'Simple',
          name: 'fairtype'
        },{
          xtype: 'radio',
          hideLabel: false,
          labelSeparator: '',
          id:'doubleRadio',
          boxLabel: 'Double',
          name: 'fairtype'
        }]
      }]
    };
     // apply config
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    // call parent initComponent
    ES.ElectricityCounter_Form.superclass.initComponent.call(this);
  } // end of function initComponent
  ,onRender:function() {
    // call parent
    ES.ElectricityCounter_Form.superclass.onRender.apply(this, arguments);
  } // eo function onRender
  ,isValid:function (){
    return(this.getField('electricitycountername').isValid());
  }
  ,hideFairType: function(){
    this.findById("simpleRadio").hide();
    this.findById("doubleRadio").hide();
    var f = this.getForm().findField('fairtype');
    f.container.up('div.x-form-item').hide();
  }
  ,setField:function(fieldName,value){
    this.getField(fieldName).setValue(value);
  }
  ,getField:function(fieldName){
    return this.getForm().findField(fieldName);
  }
});

Ext.reg('ESelectricitycounterform', ES.ElectricityCounter_Form);

