tags:

views:

441

answers:

2

As far as I can judge, the CSS-Rule "dijitRequired" is used to mark a required input field. Yet, this style is not set when I apply the "required"-Attribute to a dijit, for example, a date dijit:

The Dijit is built as follows:

<input dojoType="dijit.form.DateTextBox" class="l" id="datumsTestID" name="datumsTest"  tabindex="5" value="2009-01-01" />

The Attribute is set with the following Javscript code

dijit.byId('datumsTestID').attr('required', true)

Am I doing something wrong or is the style "dijitRequired" not intended to be used as I assume?

For my purposes, I patched ValidationTextBox.js to set/unset the class, but is there a cleaner (meaning: more correct) way to set the class or can I style required fields using other attributes?

ValidationTextBox.js, Dojo 1.3, Line 116

_setRequiredAttr:function(_12){
    this.required=_12;
    if (_12) dojo.addClass(this.domNode, "dijitRequired"); 
    else dojo.removeClass(this.domNode, "dijitRequired");
    dijit.setWaiState(this.focusNode,"required",_12);
    this._refreshState();
}
+1  A: 

Hmm, I don't see that code in ValidationTextBox.js or anywhere else. My _setRequiredAttr() in 1.3 is:

_setRequiredAttr: function(/*Boolean*/ value){
this.required = value;
dijit.setWaiState(this.focusNode,"required", value);
this._refreshState();
}

Actually I don't see any references to dijitRequired at all, maybe that's something you added to your local copy?

Bill Keese
It is true, the reference to dijitRequired ist in my local copy. I have added it because I needed the Dijit to "look" required when they are set to required.My issue is also explained in the next post: Would it be possible to add this to the Dojo ValidationTextBox, for me it looks as if my patched version (below) should be the default behaviour. Or am I missing something?
Vernade
A: 

Ihn the meanwhile we are using Dojo 1.4.3 and the issue is still the same. I am sorry, it seems I explained the issue somewhat confusingly:

The original Dojo code looks like this:

_setRequiredAttr: function(/*Boolean*/ value){
    this.required = value;
    dijit.setWaiState(this.focusNode,"required", value);
    this._refreshState();
}

But I would have expected something like this

_setRequiredAttr: function(/*Boolean*/ value){
    this.required = value;
    if (value)
            dojo.addClass(this.domNode, "dijitRequired");
    else 
            dojo.removeClass(this.domNode, "dijitRequired");
    dijit.setWaiState(this.focusNode,"required", value);
    this._refreshState();
}

Is there a reason why dijitRequired is NOT set on a required ValidationTextBox?

Vernade