Ticket #5974: 5974.patch

File 5974.patch, 2.7 kB (added by haysmark, 8 months ago)

Fixes #5974. FilteringSelect? now respects required=false. Also addressed a related bug in ComboBoxDataStore? that was causing required=false to fail to fire onChange(undefined) with blank input.

  • form/ComboBox.js

     
    10641064                //      summary:  
    10651065                //              See dojo.data.util.simpleFetch.fetch() 
    10661066                if(!args.query){ args.query = {}; } 
    1067                 if(!args.query.name){ args.query.name = "*"; } 
     1067                if(!args.query.name){ args.query.name = ""; } 
    10681068                if(!args.queryOptions){ args.queryOptions = {}; } 
    10691069                var query = "^" + args.query.name 
    10701070                                .replace(/([\\\|\(\)\[\{\^\$\+\?\.\<\>])/g, "\\$1") 
  • form/FilteringSelect.js

     
    2929                // 
    3030                _isvalid:true, 
    3131 
     32                required:true, 
     33 
    3234                _lastDisplayedValue: "", 
    3335 
    3436                isValid:function(){ 
    35                         return this._isvalid; 
     37                        return this._isvalid||(!this.required&&this.getDisplayedValue()==""); // #5974 
    3638                }, 
    3739 
    3840                _callbackSetLabel: function(    /*Array*/ result,  
     
    7476 
    7577                getValue:function(){ 
    7678                        // don't get the textbox value but rather the previously set hidden value 
    77                         return this.valueNode.value; 
     79                        return this.isValid()?this.valueNode.value:undefined; 
    7880                }, 
    7981 
    8082                _getValueField:function(){ 
  • tests/form/test_FilteringSelect.html

     
    6868        <hr> 
    6969 
    7070        <form action="#" method="GET"> 
    71                 <p>FilteringSelect #1: inlined data, autoComplete=false:</p> 
     71                <p>FilteringSelect #1: inlined data, autoComplete=false, required=false:</p> 
    7272                <label for="setvaluetest2">state list 1:</label> 
    7373                <select dojoType="dijit.form.FilteringSelect" 
    7474                                id="setvaluetest2" 
    7575                                name="state1" 
    7676                                autoComplete="false" 
     77                                required="false" 
    7778                                invalidMessage="Invalid state name" 
    7879                                onChange="dojo.byId('oc1').value=arguments[0]" 
    7980                                onFocus="console.log('user focus handler')" 
    8081                                onBlur="console.log('user blur handler')" 
    8182                > 
    82                         <option value="blank"></option> 
    8383                        <option value="AL">Alabama</option> 
    8484                        <option value="AK">Alaska</option> 
    8585                        <option value="AS">American Samoa</option> 
     
    163163                > 
    164164                <span>Value: <input id="value2" disabled></span> 
    165165 
    166                 <p>FilteringSelect #3: url, autoComplete=false:</p> 
     166                <p>FilteringSelect #3: url, autoComplete=false, required=false:</p> 
    167167                <label for="state3">state list 3:</label> 
    168168                <input searchAttr="name" 
    169169                                id="state3" 
     
    172172                                store="stateStore" 
    173173                                name="state3" 
    174174                                autoComplete="false" 
     175                                required="false" 
    175176                                onChange="setValue('value3', arguments[0]);" 
    176177                                invalidMessage="Invalid state name." 
    177178                >