cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Anderson <benanderson...@gmail.com>
Subject <fd:validation><fd:javascript>
Date Wed, 26 Oct 2005 17:31:43 GMT
Hi,
So I was trying to put javascript validation right into my form definition,
but ran into some funkiness (at least from my perspective).

First of all I realized that putting the javascript in a field doesn't
"invalidate" the form:

Here's my form definition:
<fd:validation>
<fd:javascript>
<fd:failmessage>failed on form</fd:failmessage>
cocoon.log.debug("form returning false");
return false;
</fd:javascript>
</fd:validation>
<fd:widgets>
<fd:field id="action">
<fd:label>action</fd:label>
<fd:datatype base="string"/>
<fd:validation>
<fd:javascript>
cocoon.log.debug("widget returning false");
return false;
</fd:javascript>
</fd:validation>
</fd:field>

What's interesting is that both log messages are printed. However, if I
change the <fd:javascript> on the form to return true then widget.isValid()
returns true even though my action field still returns false. CForms online
documentation for <fd:javascript> says to consult the examples in the
source. I only found one example and it is directly under the form (not the
widget).

Question #1: This leads me to believe that maybe I can't put <fd:javascript>
under the <fd:field><fd:validation> element?

Also, the <fd:failmessage> element was wishful thinking on my part which
doesn't seem to do anything. The xml of the form looks the same after the
forms transformer whether I return true or false.

Question #2: Using <fd:javascript> for validation, is there a way to get
messages printed out at all let alone something useful like this

<fd:javascript>
if (!someDAO.getOrders().size() > 0) {
// send "must attach order" message
} else if (!someOtherDAO.isValidCustomer()) {
// send "must register first" message
...

Maybe I'm just pushing the limits of the javascript validator... any ideas?
Thanks,
Ben

Mime
View raw message