Merge branch 'gilbert' into gilbert-1.3
authorStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 7 Apr 2011 16:22:55 +0000 (12:22 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 7 Apr 2011 16:22:55 +0000 (12:22 -0400)
1  2 
contrib/gilbert/static/gilbert/lib/ui/forms.js

@@@ -322,7 -322,7 +322,7 @@@ Gilbert.lib.ui.DateTimeField = Ext.exte
                // render DateField and TimeField
                // create bounding table
                var t;
-               if ('below' === this.timePosition || 'bellow' === this.timePosition) {
+               if ('below' === this.timePosition) {
                        t = Ext.DomHelper.append(ct, {
                                tag: 'table',
                                style: 'border-collapse:collapse',
         */
        ,
        isValid: function() {
-               return this.df.isValid() && this.tf.isValid();
+               var valid = true;
+               var msg = "Both fields must be supplied."
+               if (!(this.df.isValid() && this.tf.isValid())) valid = false;
+               if (Boolean(this.df.getValue()) != Boolean(this.tf.getValue())) {
+                       valid = false;
+                       if (!this.df.getValue()){
+                               if (!(this.tf.hasFocus || this.df.hasFocus)) this.df.markInvalid(msg);
+                       } else {
+                               if (!(this.tf.hasFocus || this.df.hasFocus)) this.tf.markInvalid(msg);
+                       };
+               };
+               return valid;
        }
        // eo function isValid
        // }}}
                if (d) {
                        if (! (this.dateValue instanceof Date)) {
                                this.initDateValue();
-                               if (!this.tf.getValue()) {
-                                       this.setTime(this.dateValue);
-                               }
                        }
                        this.dateValue.setMonth(0);
                        // because of leap years
                }
                else {
                        this.dateValue = '';
-                       this.setTime('');
                }
        }
        // eo function updateDate
                }
                if (t && !this.df.getValue()) {
                        this.initDateValue();
-                       this.setDate(this.dateValue);
                }
                if (this.dateValue instanceof Date) {
                        if (t) {
         */
        ,
        validate: function() {
-               return this.df.validate() && this.tf.validate();
+               var valid = true;
+               var msg = "Both fields must be supplied."
+               if (!(this.df.validate() && this.tf.validate())) valid = false;
+               if (Boolean(this.df.getValue()) != Boolean(this.tf.getValue())) {
+                       valid = false;
+                       if (!this.df.getValue()){
+                               if (!(this.tf.hasFocus || this.df.hasFocus)) this.df.markInvalid(msg);
+                       } else {
+                               if (!(this.tf.hasFocus || this.df.hasFocus)) this.tf.markInvalid(msg);
+                       };
+               };
+               return valid;
        }
        // eo function validate
        // }}}