Ext.ns('ES');

ES.SiteCharacteristicBoolForm = Ext.extend(Ext.FormPanel,{
  frame:true,
  border:true,
  height:130,
  layout:'Form',
  width: 320
  ,buttons: [{text: 'Sauver'}]
  ,initComponent:function() {
    var dt = new Date();
    var config = {
      buttonAlign:'right'
      ,frame:false
      ,border:true
      ,labelWidth:60
      ,bodyStyle:'padding:10px'
      ,items:[{
        xtype:'radio'
        ,id:'ouiRadio'
        ,name:'boolvalue'
        ,boxLabel: 'Oui'
        ,width:150
        ,fieldLabel:'Valeur'
        ,value:'0'
      },{
        xtype:'radio'
        ,id:'nonRadio'
        ,name:'boolvalue'
        ,boxLabel: 'Non'
        ,labelSeparator: ''
        ,width:150
        ,value:'1'
      },{ 
        xtype:'ESNumber'
        ,id:'radioField'
        ,name:'year'
        ,width:80
        ,minValue:1900
        ,maxValue:dt.format('Y')
        ,fieldLabel:'Depuis'
        ,allowBlank:false
//        ,anchor    : '-22'
        ,msgTarget : 'side'
//        ,msgDisplay: 'block'
      },{
        xtype:'textfield'
        ,name:'entry_id'
        ,fieldLabel:'entry id'
        ,hidden: true
        ,hideLabel: true
      }]
    };
     // apply config
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    // call parent initComponent
    ES.SiteCharacteristicBoolForm.superclass.initComponent.call(this);
    this.doLayout();
  } // end of function initComponent
  ,onRender:function() {
    // call parent
    ES.SiteCharacteristicBoolForm.superclass.onRender.apply(this, arguments);
  } // eo function onRender
  ,isValid:function (){
   return(this.getField('year').isValid());
  }
  ,getField:function(fieldName){
    switch(fieldName){
      case 'boolvaluetrue':
        return this.items.itemAt(1);
      break;
      case 'boolvaluefalse':
        return this.items.itemAt(2);
      break;
    }
    return this.getForm().findField(fieldName);
  }
  ,setField:function(fieldName,value){
    this.getField(fieldName).setValue(value);
  }
}); 

Ext.reg('ESsitecharacteristicboolform', ES.SiteCharacteristicBoolForm);

