public function process(FormRuleProcessorContext $context, FormRuleContextBuilder $collection) { $form = $context->getForm(); $formConfig = $form->getConfig(); if (!$formConfig->getCompound()) { return; } $transformer = $this->findTransformer($formConfig, 'Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\ValueToDuplicatesTransformer'); if ($transformer === null) { return; } $keys = $this->getKeys($transformer); if (empty($keys)) { return; } $formView = $context->getView(); // Use children here since we need the full_name $primary = array_shift($keys); $primaryView = $formView->children[$primary]; // Copy all rules to the first child/key element $ruleCollection = $collection->get($formView); if (!empty($ruleCollection)) { $collection->add($primaryView, $ruleCollection); } $collection->remove($formView); // Get correct error message if one is set. $invalidMessage = $this->getFormRuleMessage($formConfig); // Create equalTo rules for all other fields $equalToPrimaryRule = new TransformerRule('equalTo', FormHelper::generateCssSelector($primaryView), $invalidMessage, array(new FieldDependency($primaryView))); foreach ($keys as $childName) { $childCollection = new RuleCollection(); $childCollection->set('equalTo', $equalToPrimaryRule); $collection->add($formView->children[$childName], $childCollection); } }