Changeset 12387

Show
Ignore:
Timestamp:
02/11/08 20:17:52 (5 months ago)
Author:
doughays
Message:

Fixes #5831. Added getValue/setValue to CheckBox?. Fixed Form.html unit test.

Location:
dijit/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/CheckBox.js

    r11982 r12387  
    3333                //      equivalent to value field on normal checkbox (if checked, the value is passed as 
    3434                //      the value when form is submitted) 
    35                 value: "on" 
     35                value: "on", 
     36 
     37                setValue: function(/*String or Boolean*/ newValue){ 
     38                        // summary: set the value of the widget. 
     39                        if(typeof newValue == "string"){ 
     40                                this.setAttribute('value', newValue); 
     41                                newValue = true; 
     42                        } 
     43                        this.setAttribute('checked', newValue); 
     44                }, 
     45 
     46                _getValueDeprecated: false, // remove when _FormWidget:getValue is removed 
     47                getValue: function(){ 
     48                        // summary: get the value of the widget. 
     49                        return (this.checked ? this.value : false); 
     50                } 
    3651        } 
    3752); 
  • dijit/trunk/form/Form.js

    r12262 r12387  
    4747                                        // for checkbox/radio, values is a list of which widgets should be checked 
    4848                                        dojo.forEach(widgets, function(w, i){ 
    49                                                 w.setAttribute('checked', (dojo.indexOf(values, w.value) != -1)); 
     49                                                w.setValue(dojo.indexOf(values, w.value) != -1); 
    5050                                        }); 
    5151                                }else if(widgets[0].setValues){ 
     
    152152                                                if(/Radio/.test(widget.declaredClass)){ 
    153153                                                        // radio button 
    154                                                         if(widget.checked){ 
     154                                                        if(value !== false){ 
    155155                                                                dojo.setObject(name, value, obj); 
    156156                                                        } 
     
    162162                                                                dojo.setObject(name, ary, obj); 
    163163                                                        } 
    164                                                         if(widget.checked){ 
     164                                                        if(value !== false){ 
    165165                                                                ary.push(value); 
    166166                                                        } 
  • dijit/trunk/form/SimpleTextarea.js

    r12384 r12387  
    3535 
    3636        setValue: function(/*String*/ val){ 
    37                 this.domNode.value = this.value = val; 
     37                this.domNode.value = val; 
    3838                this.inherited(arguments); 
    3939        }, 
    4040 
    4141        getValue: function(){ 
    42                 return this.domNode.value; 
     42                return this.domNode.value.replace(/\r/g,""); 
    4343        } 
    4444}); 
  • dijit/trunk/form/Textarea.js

    r12184 r12387  
    108108 
    109109        getValue: function(){ 
    110                 return this.formValueNode.value.replace(/\r/g,""); 
     110                return this.value.replace(/\r/g,""); 
    111111        }, 
    112112 
  • dijit/trunk/form/_FormWidget.js

    r12282 r12387  
    295295        setValue: function(/*anything*/ newValue, /*Boolean, optional*/ priorityChange){ 
    296296                // summary: set the value of the widget. 
     297                this.value = newValue; 
    297298                this._handleOnChange(newValue, priorityChange); 
    298299        }, 
  • dijit/trunk/tests/form/Form.html

    r12261 r12387  
    5858                                                        t1: "line 1\nline 2", 
    5959                                                        st1: "simple line 1\nsimple line 2", 
    60                                                         richtext: "<h1>original</h1><p>This is the default content</p>" 
     60                                                        richtext: "<h1>original</h1><p>This is the default content</p>", 
     61                                                        filename: "" 
    6162                                                }; 
    6263 
     
    7273                                                        t1: "new line 1\nnew line 2", 
    7374                                                        st1: "new simple line 1\nnew simple line 2", 
    74                                                         richtext: "<h1>changed</h1><p>This is the changed content set by setValues</p>" 
     75                                                        richtext: "<h1>changed</h1><p>This is the changed content set by setValues</p>", 
     76                                                        filename: "" 
    7577                                                }; 
    7678