Roo/form/ComboBoxArray.js
[roojs1] / Roo / form / MonthField.js
index 214c3f2..68796d9 100644 (file)
@@ -250,6 +250,10 @@ monthField.setValue('2006-5-4');
      */
     setValue : function(date){
         Roo.log('month setValue' + date);
+        // can only be first of month..
+        
+        var val = this.parseDate(date);
+        
         if (this.hiddenField) {
             this.hiddenField.value = this.formatDate(this.parseDate(date), 'Y-m-d');
         }
@@ -260,12 +264,17 @@ monthField.setValue('2006-5-4');
     // private
     parseDate : function(value){
         if(!value || value instanceof Date){
+            value = value ? Date.parseDate(value.format('Y-m') + '-01', 'Y-m-d') : null;
             return value;
         }
         var v = Date.parseDate(value, this.format);
-        if (this.useIso) {
+        if (!v && this.useIso) {
             v = Date.parseDate(value, 'Y-m-d');
         }
+        if (v) {
+            // 
+            v = Date.parseDate(v.format('Y-m') +'-01', 'Y-m-d');
+        }
         
         
         if(!v && this.altFormats){
@@ -347,7 +356,7 @@ monthField.setValue('2006-5-4');
                     this.monthPicker.hide();
                 }else{
                     this.monthPicker.slideOut('t', {duration:.2});
-                    p.setValue(new Date(m.picker.mpSelYear, m.picker.mpSelMonth));
+                    p.setValue(new Date(m.picker.mpSelYear, m.picker.mpSelMonth, 1));
                     p.fireEvent("select", this, this.value);
                     m.hide();
                 }