Hi Amr
Thanks for the reply - yes, I'd found out about the 'context' argument
when I used the password confirm demo as a starting point for some
other validators that compare fields within the form.
The reason I didn't choose 1 is that I didn't necessarily want each
element being responsible for checking the other ones - there may be a
variable number of elements within this subgroup and may not always be
named the same.
Also since this check is essentially to validate the subform and not
the elements themselves, I was hoping to direct error messages to
inside the <fieldset> rather than for the first element. It seems more
logical to me to ask the subform if there's a minimum/maximum number
of valid elements rather than performing it at element-level.
I guess I can run with option 2 but I also need to work out where I
can generate an error message if at least 1 of these text boxes has
not value.
Food for thought...
Cheers!
Hi Simon,
If I understand you correctly, I can see two ways:
Using per element validators using the second parameter to isValid()
which is "context" which contains the data of the whole form so you
can also check, I think there is an example that uses it in the
manual.
Overriding the subForm's isValid. The only problem you will face is
that you will not be able to set the error message on the elements
as they can be set from inside the element only (there is an issue
for this in the tracker btw). But you can get around this I'm sure.
Best Regards,
- Amr
--
Simon Mundy | Director | PEPTOLAB
""" " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654
4124
http://www.peptolab.com