I have two text input fields in a form. At least one of them is required. My question is, how can I check for this?
class MyManipulator = (formfields.Manipulator): def __init__(self, request=None): self.fields = [ formfields.TextField( field_name='apples', length=5, ), self.fields = [ formfields.TextField( field_name='pears', length=5, ), ] The problem is, I cannot use is_required=True. I can use another field and make it is_required=True and define another validator - this is what I'm doing now: .... self.fields = ..... formfields.TextField( field_name='basket', length=5, is_required=True, validator_list=[apples_or_pears], ), .... def apples_or_pears(self, field_data, all_data): if not all_data.get('apples', '') and not all_data.get('pears', ''): raise validator.ValidationError, _('bummer - what now?') .... This is a hack and has several drawbacks, such as it does not belong to the correct field, and is within an unexpected field's validator list. Thank you for your suggestions. Jiri