How to make a Field injected multiple times to the Form unique in ZF2?

100 Views Asked by At

I have a pretty complex form with several nested Fieldsets and Collections. Some parts of the form are constant, other parts are variable:

BasicSettings EndpointBasicSource (constant part) EndpointBasicTarget (constant part) SpecificSettings EndpointType{TYPE}Source (variable part) EndpointType{TYPE}Target (variable part)

The EndpointBasicSource and EndpointBasicTarget contain a ServerFieldset, that provides the Field server_name. That means: The form contains at least 2 server_name Fields.

In the SpecificSettings depending on the EndpintType no, one, or both sides can contain a servers Collection (options.target_element.type => ServerFieldset) with up to 5 servers in it.

Here is a strongly simplified schema:

enter image description here

Now the servers should get unique (in all the server_name fields in the form a value may not recur). But how to do this? The problem is, that the ServerFieldset is injected via multiple other Fieldsets/Collections and the uniqueness validation needs to relate to the server_name Fields in all of them.

How can this problem be solved and a uniqueness validation for all the server_name in the entire form implemented?

0

There are 0 best solutions below