[Erp5-dev] Validation of multiple fields on one form

Łukasz Nowak lukasz.nowak at ventis.com.pl
Thu Apr 17 11:25:34 CEST 2008


Hello,

On 2008-04-16, 16:12:59
Mikolaj Antoszkiewicz <mikolaj at erp5.pl> wrote:

> > Hello,
> > 
> > On 2008-04-16, 15:41:15
> > Mikolaj Antoszkiewicz <mikolaj at erp5.pl> wrote:
> > 
> >> Hello,
> >>
> >> I've just came across such an issue:
> >>
> >> I'm trying to validate if a given user (actually a pair First+Last
> >> Name) was already saved (used) in the system.
> >>
> >> Well, the problem is that I'd like to check both fields at the
> >> same time, but the validating script gets only a field value from
> >> the field it's attached to.
> >> I've used the Request object passed also to the validating script,
> >> to get both last and first name values, but it looks a bit ugly.
> >>
> >> Is there any 'nicer' way of doing such a validation?
> > 
> > As far as I understood you are trying to validate data of object,
> > using user interface?
> > 
> > Wouldn't it be nicer to use proper Constraint for this type, and
> > invoke checkConsistency while validating object?
>  >
> Well, sure, but I doubt You'll find a user which has to enter daily
> and in a hurry, few Persons and then an Event or two for each of
> them, to validate each Person with the workflow transition.
> 
> Also, after it's been successfully validated, Person object is still 
> editable - so much for consistency check.
> 
> Sure, it could be read-only after validation, but then each and every 
> small change to it's details, would mean two additional transitions
> (at least 7 clicks - if everything is valid :) ). So in a case where
> there is a need for a 'mass' change in a group of Persons, I can
> picture a regular user throwing a computer through the window and
> jumping after it after first 30 cliks...
> 
> > Using mass workflow transition with some asynchronous messaging
> > would give possibility to:
> >  a mass data insertion
> >  b then mass data validation
> >  c mass data edition, goto b until wrong objects left
> > 
> No mass data operations on Person type objects is to be expected here.
> 
> > And there might be some kind of tooltip on object, which would show
> > checkConsistency messages on object, while edited by user (eg. list
> > presence of duplications etc).
> >
> At which point that tooltip would appear?

All the time. As readonly field on view.

> > That's a way, we are implementing such constraining in our
> > implementation.
> > 
> > Regards,
> > Luke
> 
> Anyway, You haven't mentioned what is 'not nice' in my approach?
> Field validators are there exactly for validation of data using user
> interface.

AFAIK you are validating object data in UI. What about if you provide
another form, or dialog in which you forget to validate that data?

But as generic idea: I thinking only about convention, that data shall
be validated on data layer, not on user interface layer. Checking for
proper values in fields (eg. proper date in DateTimeField) is something
else.

I think I *feel* what is the problem, and this is related with
limitation of UI based on HTTP without some kind of client-side helper
(eg. AJAX). You need to provide information based on data gathered in
system, and let user to be able to make fast (1-2 sec), on-click,
decision. So what you suggested might be acceptable workaround, until
user-friendly generic layer would come :)

Just thinking, as we had similar problems.

Regards,
Luke

-- 
Łukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.



More information about the Erp5-dev mailing list