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

Mikolaj Antoszkiewicz mikolaj at erp5.pl
Wed Apr 16 16:12:59 CEST 2008



Łukasz Nowak 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?

> 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.

Regards,
Mikolaj



More information about the Erp5-dev mailing list