I saw that the validate method doesn't check for extra validations. I think you need somethink like this:
<fd:booleanfield id="read_law">
<fd:validation>
<fd:javascript>
return widget.getValue == java.lang.Boolean.TRUE;
</fd:javascript>
</fd:validation>
</fd:field>
I tracked the problem a little further down. First, you need to remove
the validate() method in BooleanField.java. After that, you need to
modify the BooleanFieldDefinitionBuilder.java a little. You need to add
the statement
setValidators(widgetElement, definition); in the buildWidgetDefinition
method, just before the new widget definition is returned. Third thing
to do is to implement ValidationErrorAware on BooleanField.java.
Also, you need to modify the field styling to show the validation error
on the form (I don't have time for that).
I've made the modification (see attachment - they work for me), but I
think it would be wise to discuss these changes on the dev mailing list.
Bart.
-----Original Message-----
From: Patrick Verboom [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 01, 2004 2:01 PM
To: [EMAIL PROTECTED]
Subject: Re: CForms booleanfield validate problem
Hi Bart,
It is a law thing. The user needs to agree before he may continue in the
flow. So I wanted to validate the form and look if the check box was
checked if not set an validate error message. The problem is that in the
validate method of the form the boolean field always false is. Now I
have to use a while loop in the flow script that checks the boolean
field. I don't think this isn't the way it is supposed to be.
greetings patrick
Bart Molenkamp wrote:
>Hi Patrick,
>
>What do you want to validate about a boolean field?
>A boolean field can only contain valid values. It's value, either true
>or false, are always valid values for a boolean. So it returns always
>true. See this code snippet from BooleanField.java:
> /**
> * Always return <code>true</code> (an action has no validation)
> *
> * TODO is there a use case for boolean fields having validators?
> */
> public boolean validate() {
> // a boolean field is always valid
> return true;
> }
>
>But maybe I don't understand your question.
>Bart.
>
>-----Original Message-----
>From: Patrick Verboom [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, September 01, 2004 11:04 AM
>To: [EMAIL PROTECTED]
>Subject: CForms booleanfield validate problem
>
>Hi,
>
>How do you validate a boolean field?
>I tried to use my own validate method on the complete form but the
>boolean field keeps sending me a false. It doesn't mater if I select or
>deselect the check box the thing keeps giving me a false.
>I now created a not so elegant solution over a hidden field and a
>on-value-change but there must be a better solution.
>
>Greetings Patrick
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
BooleanField.java
Description: BooleanField.java
BooleanFieldDefinitionBuilder.java
Description: BooleanFieldDefinitionBuilder.java
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
