bug: xforms-required-filled/xforms-required-empty classes not being updated on upload control

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

bug: xforms-required-filled/xforms-required-empty classes not being updated on upload control

Adrian Baker
I found that xforms.js was never updating the xforms-required-filled/xforms-required-empty classes of an upload control: after a single upload, all upload controls on a form would change to xforms-required-filled, even if empty & required.

A fix is to extend the
ORBEON.xforms.Controls.updateRequiredEmpty to check for the upload state (we can't just check for value because once a file has been uploaded from the browser the html file input gets cleared):

    updateRequiredEmpty: function(control) {
        if (ORBEON.util.Dom.hasClass(control, "xforms-required")) {
            if(ORBEON.util.Dom.hasClass(control, "xforms-upload") && ORBEON.util.Dom.getAttribute(control, "state") == "file") {
                ORBEON.util.Dom.addClass(control, "xforms-required-filled");
                ORBEON.util.Dom.removeClass(control, "xforms-required-empty");
            } else if (ORBEON.xforms.Controls.getCurrentValue(control) == "") {
                ORBEON.util.Dom.addClass(control, "xforms-required-empty");
                ORBEON.util.Dom.removeClass(control, "xforms-required-filled");
            } else {
                ORBEON.util.Dom.addClass(control, "xforms-required-filled");
                ORBEON.util.Dom.removeClass(control, "xforms-required-empty");
            }
        } else {
            ORBEON.util.Dom.removeClass(control, "xforms-required-filled");
            ORBEON.util.Dom.removeClass(control, "xforms-required-empty");
        }
    },

Also though, we probably want to style a selected-but-not-uploaded upload as xforms-required-filled. My attempt at this was to change ORBEON.xforms.Controls.
getCurrentValue:

    getCurrentValue: function(control) {
       ...
        } else if(ORBEON.util.Dom.hasClass(control, "xforms-upload")) {
            return ORBEON.util.Dom.getChildElementByClass(control, "xforms-upload-select").value;
        } else {
            return control.value;
        }
    },

This isn't quite perfect because the xforms-required-empty class isn't removed as soon as you select a file: you have to go into the upload field and hit enter before it goes. Have run out of time to look at this  further however.

Adrian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: bug: xforms-required-filled/xforms-required-empty classes not being updated on upload control

Alessandro Vernet
Administrator
Adrian,

On 9/6/07, Adrian Baker <[hidden email]> wrote:
>  This isn't quite perfect because the xforms-required-empty class isn't
> removed as soon as you select a file: you have to go into the upload field
> and hit enter before it goes. Have run out of time to look at this  further
> however.

We get a change event when a file is selected (this is what we use to
trigger an xforms-select). So you might want to improve in this by
adding something to ORBEON.xforms.Events.change(). Let us know if you
get a chance to do this.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws