On Thu, 2004-07-01 at 12:09, Jeremy Quinn wrote:
> On 30 Jun 2004, at 17:56, Bruno Dumon wrote:
> 
> Thanks for your response Bruno.
> 
> > On Wed, 2004-06-30 at 13:01, Jeremy Quinn wrote:
> >> Hi All
> >>
> >> I need to validate (within the CForms framework) that a set of
> >> checkboxes have all been checked.
> >>
> >> I have tried adding <fd:validation/> but it does not appear to have an
> >> effect :
> >
> > Checked the source: it's indeed not supported. Probably for no
> > particular reason.
> >
> > Possible options are:
> >
> > * adding support for it.
> 
> sounds good
> 
> > Should be no more then adding the following
> > line to the class BooleanFieldDefinitionBuilder:
> > setValidators(widgetElement, definition);
> > I don't have time to test that, but since you already have an example
> > worked out you could give it a try.
> 
> OK, I added setValidators(widgetElement, definition); at line 34, in 
> the buildWidgetDefinition method.
> 
> I then test with the following booleanfield:
> 
> <fd:booleanfield id="mod-copyright">
>    <fd:label>
>      <i18n:text 
> i18n:catalogue="local">moderate.mod-copyright.label</i18n:text>:
>    </fd:label>
>    <fd:hint>
>      <i18n:text 
> i18n:catalogue="local">moderate.mod-copyright.hint</i18n:text>
>    </fd:hint>
>    <fd:help>
>      <i18n:text 
> i18n:catalogue="local">moderate.mod-copyright.help</i18n:text>
>    </fd:help>
>    <fd:validation>
>      <fd:assert test="mod-copyright = True()">
>        <fd:failmessage>
>          <i18n:text 
> i18n:catalogue="local">moderate.mod-copyright.fail</i18n:text>
>        </fd:failmessage>
>      </fd:assert>
>    </fd:validation>
> </fd:booleanfield>
> 
> When I submit this form with the checkbox unchecked, I get no 
> validation error displayed.
> 
> Comparing Field to BooleanField, it looks like BooleanField needs to 
> implement ValidationErrorAware, so I will try that next.

I also see that the class BooleanField defines the validate method to do
nothing. Just throw that method out (the one from the parent class will
take over).

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED]                          [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to