> Van: Sylvain Wallez [mailto:[EMAIL PROTECTED] > > Bart Molenkamp wrote: > > > > > > >I'm not sure, but I think it is because a form doesn't have a visual > representation in HTML, where other widgets do have a visual > representation. Where should CForms place the error marker (the red "!") > for a form? > > > > > > That's exactly the reason: only widgets who have a visual representation > can be made validation-aware, as otherwise we don't know how/where to > display the error. > > >I agree that it will be helpful to have this feature. And I think that > repeaters are a similar case (aren't ValidationErrorAware either, but I > have cases here where I want it to hold an error instead of creating a > messages widget). > > > > > > The form1 sample has a validator on the "contacts" repeater, which > checks uniqueness of {firstName,lastName} on the various rows. If a > duplicate is found, the error is set on the offending row as its the > most precise location indicating to the user where the problem is. > Attaching the error to the repeater itself would make finding the > problem more difficult.
It would be nice to set an error on the repeater if it has no rows, and at least one row is required. > > The same reasoning can be applied to the form object. Since an error > means the user has to change something, then we'd better indicate > precisely what should be changed. Now in some cases the error can be of > type "either change this _or_ change that" and that's where the message > widget is usefull. > > Hmm... > > Now there's also the little-known <ft:validation-error> template > instruction that outputs the validation error or any given widget. This > can be a good replacement of the message widget, and would allow > non-visual widgets to be ValidationAware. > > WDYT? > So, then all widgets can implement ValidationErrorAware. For most widgets, the forms-styling.xsl knows how to display the error. For the other, special cases we could use <ft:validation-error> to display the error. Am I correct on this? If so, it seems like a good solution to me. Bart.
