How to make a field validation dependent on a field of another Fieldset in ZF2?

69 Views Asked by At

In my form I have some fields, that should be validated depending on some field(-s) in another sub-fieldset of the Form:

MyForm
- [fieldset] main instanceof WhatEverFieldset
-- [fieldset] foo instanceof FooFieldset
--- [field] field_a
--- [field] field_b
-- [fieldset] bar instanceof BarFieldset
--- [field] field_c
--- [fieldset] xyz instanceof XyzFieldset
---- [field] field_d
-- [fieldset] buz instanceof BuzFieldset
---- [field] field_e
--- [fieldset] xyz instanceof XyzFieldset
---- [field] field_d

So there are some validation rules to implement, that effect the fields of multiple fieldsets. E.g.:

  • At least form.main.*.xyz.field_d has to be set. That means, I cannot define a required rule directly in the XyzFieldset, since there is a a condition and it for it's located outside of the XyzFieldset.

  • The value of form.main.foo.field_a has to be grater than the value of form.main.bar.field_c.

Where / How to define validation rules, that depend on fields' values of other sub-fieldsets of the form?

0

There are 0 best solutions below