Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#8917 closed enhancement (fixed)

FilteringSelect: If required="false", set custom valid DefaultValue

Reported by: thekryz Owned by:
Priority: high Milestone: 1.5
Component: Dijit - Form Version: 1.2.3
Keywords: FilteringSelect displayedvalue validation Cc:
Blocked By: Blocking:

Description

At the moment (since [13989]) with a FilteringSelect? and required="false", it is okay to leave the FilteringSelect? blank and it will be accepted when submitting a form. My suggestion is, that a user can enter a custom Default Value (other than the atm hard-coded "") for the FilteringSelect?.

My reason for this: I am using FilteringSelects? in my form, that display a default value using displayedvalue like this:

<select dojotype="dijit.form.FilteringSelect"
        displayedvalue="Please choose"
        required="false" name="myName">
    <option value="#LOW">Low</option>
    <option value="#HIGH">High</option>
</select>

Now I have some FilteringSelects? on the page that are required, but this one is not supposed to be. I'd therefor like my displayedvalue to be "valid" in the sense that the FilteringSelect? returns no value, but doesn't show me that it's invalid and can send the form.

This is also about a better handling of Default Values in FilteringSelects? - maybe the two issues can have one solution?

Change History (5)

comment:1 Changed 10 years ago by thekryz

I did my own custom widget for now like this:

dojo.provide("myDojo.DefaultValueFilteringSelect");
dojo.require("dijit.form.FilteringSelect");
dojo.declare("myDojo.DefaultValueFilteringSelect",
    [ dijit.form.FilteringSelect ],
    {
        defaultValue:"",
        
        isValid:function(){
            return this._isvalid || (!this.required && this.getDisplayedValue() == this.defaultValue);
        }
        
        getValue: function(	/* item */ item, 
                            /* attribute-name-string */ attribute, 
                            /* value? */ defaultValue){
            var value = (attribute == "value") ? item.value : (item.innerText || item.textContent || '');
            /* Check if value is DefaultValue, if yes - return "" */
            if(value == defaultValue){
                value = "";
            }
            return value;
        },

            
    }
);

There, you can enter an defaultValue instead of having to go with "" as a valid default.

comment:2 Changed 10 years ago by Douglas Hays

Milestone: 1.4future

comment:3 Changed 9 years ago by haysmark

Resolution: fixed
Status: newclosed

We now have the placeHolder attribute on all TextBox? widgets that does exactly this.

comment:4 Changed 9 years ago by Douglas Hays

Milestone: future1.5

comment:5 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.