public function process(FormRuleProcessorContext $context, FormRuleContextBuilder $formRuleContext) { $form = $context->getForm(); $formConfig = $form->getConfig(); if (!$formConfig->getCompound() || $context->getConstraints()->count() === 0) { return; } $formView = $context->getView(); $rules = $formRuleContext->get($formView); if ($rules === null || $rules->count() === 0 || !$this->requiresCopy($form)) { return; } $this->registerRulesForChildren($formRuleContext, $formView, $this->getFormRuleMessage($formConfig)); }
public function process(FormRuleProcessorContext $processContext, FormRuleContextBuilder $formRuleContext) { $constraints = $processContext->getConstraints(); $form = $processContext->getForm(); $collection = new RuleCollection(); foreach ($this->mappers as $mapper) { foreach ($constraints as $constraint) { if (!$mapper->supports($constraint, $form)) { continue; } $mapper->resolve($constraint, $form, $collection); } } $formRuleContext->add($processContext->getView(), $collection); }
public function process(FormRuleProcessorContext $processContext, FormRuleContextBuilder $formRuleContext) { $form = $processContext->getForm(); if (!$this->requiresValidConstraint($form) || $this->hasValidConstraint($processContext->getConstraints())) { return; } $view = $processContext->getView(); $it = new \RecursiveIteratorIterator(new FormViewRecursiveIterator($view->getIterator()), \RecursiveIteratorIterator::SELF_FIRST); foreach ($it as $childView) { if (isset($childView->vars['required'])) { $childView->vars['required'] = false; } $this->cleanChildRules($childView, $formRuleContext); } }
public function process(FormRuleProcessorContext $processContext, FormRuleContextBuilder $formRuleContext) { $view = $processContext->getView(); if (!isset($view->vars['required'])) { return; } // Check if the field is really required according to HTML validation // (aka the required for symfony form means it needs to be submitted but maybe null or "") $constraints = $processContext->getConstraints(); foreach ($constraints as $constraint) { if (in_array(get_class($constraint), static::$requiredConstraintClasses, true)) { $view->vars['required'] = true; return; } } $view->vars['required'] = false; }