Create a validation broker object for $form

@param \FormObject\Form $form
@return \FormObject\Validation\BrokerInterface
198660
public function createBroker(Form $form)
    {
        $broker = new AutoValidatorBroker($this->validatorFactory);
        $broker->setForm($form);
        return $broker;
    }
1053790
public function createForm($form) {
        $params = array();
        foreach ($form as $key => $value) {
            foreach ($value as $k => $v) {
                if ($key == "properties") {
                    $params["{$key}[{$k}]"] = $v;
                } else {
                    foreach ($v as $a => $b) {
                        $params["{$key}[{$k}][{$a}]"] = $b;
                    }
                }
            }
        }
        return $this->_executePostRequest('user/forms', $params);
    }
62736
public function getRootFormCascadeOption(FormInterface $form)
    {
        if (! $form->isRoot()) {
            return $this->getRootFormCascadeOption($form->getParent());
        }

        return $form->getConfig()->getOption('cascade_filter', false);
    }
1349379
protected function getValidationData(Form $form)
    {
        // If parent has metadata
        $parent = $form->getParent();
        if ($parent && null !== $parent->getConfig()->getDataClass()) {
            $classMetadata = $metadata = $this->getMetadataFor($parent->getConfig()->getDataClass());
            if ($classMetadata->hasPropertyMetadata($form->getName())) {
                $metadata = $classMetadata->getPropertyMetadata($form->getName());
                /** @var PropertyMetadata $item */
                foreach ($metadata as $item) {
                    $this->composeValidationData(
                        $parentData,
                        $item->getConstraints(),
                        $getters = !empty($item->getters) ? (array)$item->getters : array()
                    );
                }
            }
        }
        // If has own metadata
        if (null !== $form->getConfig()->getDataClass()) {
            $metadata = $this->getMetadataFor($form->getConfig()->getDataClass());
            $this->composeValidationData(
                $ownData,
                $metadata->getConstraints(),
                $getters = !empty($metadata->getters) ? (array)$metadata->getters : array()
            );
        }
        // If has constraints in a form element
        $this->composeValidationData(
            $formData,
            (array)$form->getConfig()->getOption('constraints'),
            array()
        );

        $result = array();
        $groups = $this->getValidationGroups($form);

        if (!empty($parentData)) {
            $parentData['groups'] = $this->getValidationGroups($parent);
            $result['parent']     = $parentData;
        }
        if (!empty($ownData)) {
            $ownData['groups'] = $groups;
            $result['entity']  = $ownData;
        }
        if (!empty($formData)) {
            $formData['groups'] = $groups;
            $result['form']     = $formData;
        }

        return $result;
    }
1141536
protected function addMember($form)
    {
        $member   = new Member();
        $groupIds = $this->getSettableGroupIdsFrom($form);

        $form->saveInto($member);

        $member->ProfilePageID   = $this->ID;
        $member->NeedsValidation = ($this->EmailType === 'Validation');
        $member->NeedsApproval   = $this->RequireApproval;

        try {
            $member->write();
        } catch (ValidationException $e) {
            $validationMessages = implode("; ", $e->getResult()->getMessages());
            $form->sessionMessage($validationMessages, 'bad');
            return null;
        }

        // set after member is created otherwise the member object does not exist
        $member->Groups()->setByIDList($groupIds);

        // If we require admin approval, send an email to the admin and delay
        // sending an email to the member.
        if ($this->RequireApproval) {
            $groups = $this->ApprovalGroups();
            if (!$groups ||
                $groups->count() == 0) {
                // If nothing is configured, fallback to ADMIN
                $groups = Permission::get_groups_by_permission('ADMIN');
            }

            $emails = [];
            if ($groups) {
                foreach ($groups as $group) {
                    foreach ($group->Members() as $_member) {
                        if ($_member->Email) {
                            $emails[] = $_member->Email;
                        }
                    }
                }
            }

            if ($emails) {
                $emails = array_unique($emails);

                $mail   = Email::create();
                $config  = SiteConfig::current_site_config();
                $approve = Controller::join_links(
                    Director::baseURL(),
                    'member-approval',
                    $member->ID,
                    '?token=' . $member->ValidationKey
                );

                $mail->setSubject("Registration Approval Requested for $config->Title");
                foreach ($emails as $email) {
                    if (!Email::is_valid_address($email)) {
                        // Ignore invalid email addresses or else we'll get validation errors.
                        // ie. default 'admin' account
                        continue;
                    }
                    $mail->addBCC($email);
                }
                $mail->setHTMLTemplate('Symbiote\\MemberProfiles\\Email\\MemberRequiresApprovalEmail');
                $mail->setData(array(
                    'SiteConfig'  => $config,
                    'Member'      => $member,
                    'ApproveLink' => Director::absoluteURL($approve)
                ));

                $mail->send();
            }
        } else {
            // NOTE(Jake): 2018-05-03
            //
            // Only send the confirmation email immediately after registering if they
            // don't require admin approval.
            //
            switch ($this->EmailType) {
                case 'None':
                    // Does not require anything
                break;

                case 'Confirmation':
                case 'Validation':
                    // Must activate themselves via the confirmation email
                    $email = MemberConfirmationEmail::create($this->data(), $member);
                    $email->send();
                break;
            }
        }

        $this->extend('onAddMember', $member);
        return $member;
    }
517669
public function save(Form $form)
    {
        $this->em->persist($form);
        $this->em->flush();

        return $form;
    }
1087058
protected function extendForm(FormBuilder $form)
    {
        $form->extend(function(FormGrid $form) {
            $fieldsetName = trans('antares/ban_management::title.config.title');

            $form->findFieldsetOrCreateNew($fieldsetName, function(Fieldset $fieldset) use($fieldsetName) {
                $fieldset->legend($fieldsetName);
                $rules = $this->rulesProcessor->getWhitelist()->map(function(RuleContract $rule) {
                            return $rule->getValue();
                        })->toArray();

                $fieldset->control('input:text', 'ban-management[options][max_failed_attempts]')
                        ->value($this->config->getMaxFailedAttempts())
                        ->label(trans('antares/ban_management::label.config.max-attempts'));

                $fieldset->control('input:textarea', 'ban-management[rules][ip-whitelist]')
                        ->value(implode("\r\n", $rules))
                        ->label(trans('antares/ban_management::label.config.ip-whitelist'))
                        ->attributes(['rows' => 5, 'cols' => 50])
                        ->help(trans('antares/ban_management::label.config.ip_whitelist_help'));

                $fieldset->control('input:text', 'cancel')
                        ->label('')
                        ->field(function() {
                            return app('html')->link(handles("antares::ban_management/rules/datatable"), trans('antares/ban_management::title.go_to_ban_management'));
                        });
            });
        });
    }
1117778
public function validateGhost($form, $initialize = true)
    {
        if ($initialize) {
            $this->initializeValidator($form);
        }

        $this->isValid($form);

        return $this->result;
    }
378756
public function setForm($form)
    {
        // Associate Form Instance (via parent):
        
        parent::setForm($form);
        
        // Associate Rules with Fields:
        
        foreach ($this->rules as $fieldName => $rules) {
            
            if ($field = $this->getDataField($fieldName)) {
                
                foreach ($rules as $rule) {
                    $rule->setField($field);
                }
                
            }
            
        }
        
        // Associate Backend with Self:
        
        $this->backend->setFrontend($this);
        
        // Initialise Backend:
        
        $this->backend->doInit();
        
        // Define Form Classes:
        
        if ($classes = $this->getClassesForForm($form)) {
            
            foreach ($classes as $class) {
                $form->addExtraClass($class);
            }
            
        }
        
        // Define Form Attributes:
        
        if ($attributes = $this->getAttributesForForm($form)) {
            
            foreach ($attributes as $key => $value) {
                $form->setAttribute($key, $value);
            }
            
        }
        
        // Answer Self:
        
        return $this;
    }
1210532
public function createFormView(FormInterface $form)
    {
        $post = $this->eavManager->initializeEntity($form->getSchema());

        $form = $this->formFactory->create(PostType::class, $post, ['form_id' => $form->getId()]);

        return $form->createView();
    }
237419
public function getSchema(Form $form)
    {
        $schema = [
            'name' => $form->getName(),
            'id' => $form->FormName(),
            'action' => $form->FormAction(),
            'method' => $form->FormMethod(),
            'attributes' => $form->getAttributes(),
            'data' => [],
            'fields' => [],
            'actions' => []
        ];

        /** @var FormField $action */
        foreach ($form->Actions() as $action) {
            $schema['actions'][] = $action->getSchemaData();
        }

        /** @var FormField $field */
        foreach ($form->Fields() as $field) {
            $schema['fields'][] = $field->getSchemaData();
        }

        return $schema;
    }
889996
public function register()
    {

        $this->app->afterResolving(Form::class, function (Form $form) {
            $this->forwardLegacyEvents($form);
        });

        Form::provideValidationBroker(function(Form $form) {

            $broker = new AutoValidatorBroker(new ValidatorFactory());
            $broker->setForm($form);

            $broker->onAfter('setValidator', function ($validator) use ($form) {
                $formName = $form->getName();
                $this->app['events']->fire("form.validator-setted.$formName", [$validator]);
            });
            return $broker;

        });

        Form::provideRequestProvider(function(){
            return $this->getRequestProvider();
        });


        Form::provideUrlProvider(function(){
            return $this->getActionUrlProvider();
        });

        Form::provideRenderer(function(){
            return $this->getRenderer();
        });

        Form::provideAdditionalNamer(function($chain){
            $chain->append($this->getTranslationNamer());
        });

        Form::onRendererChanged(function ($renderer) {
            $this->app['events']->fire('form.renderer-changed', [$renderer]);
            $this->addFormPaths($renderer);
        });

        $this->app->alias('formobject.factory', 'FormObject\Factory');

        $this->app->singleton('formobject.factory', function($app){
            $factory = Form::getFactory();
            $factory->createFieldsWith(function($class) {
                return $this->app->make($class);
            });
            return $factory;
        });

        $this->app->afterResolving('XType\Casting\Contracts\InputCaster', function($caster) {
            $this->registerInputCasters($caster);
        });


    }
349032
public function indexAction($form = null)
    {
        $form = $form ?: $this->createForm(BasketType::class, $this->get('sonata.basket'), [
            'validation_groups' => ['elements'],
        ]);

        // always validate the basket
        if (!$form->isSubmitted()) {
            if ($violations = $this->get('validator')->validate($form)) {
                $violationMapper = new ViolationMapper();
                foreach ($violations as $violation) {
                    $violationMapper->mapViolation($violation, $form, true);
                }
            }
        }

        $this->get('session')->set('sonata_basket_delivery_redirect', 'sonata_basket_delivery_address');

        $this->get('sonata.seo.page')->setTitle($this->get('translator')->trans('basket_index_title', [], 'SonataBasketBundle'));

        return $this->render('SonataBasketBundle:Basket:index.html.twig', [
            'basket' => $this->get('sonata.basket'),
            'form' => $form->createView(),
        ]);
    }
186469
public function validateForm(FormEvent $event)
    {
        $form = $event->getForm();

        if ($form->isRoot()) {
            // Form groups are validated internally (FormValidator). Here we don't set groups as they are retrieved into the validator.
            foreach ($this->validator->validate($form) as $violation) {
                // Allow the "invalid" constraint to be put onto
                // non-synchronized forms
                // ConstraintViolation::getConstraint() must not expect to provide a constraint as long as Symfony\Component\Validator\ExecutionContext exists (before 3.0)
                $allowNonSynchronized = (null === $violation->getConstraint() || $violation->getConstraint() instanceof Form) && Form::NOT_SYNCHRONIZED_ERROR === $violation->getCode();

                $this->violationMapper->mapViolation($violation, $form, $allowNonSynchronized);
            }
        }
    }
1365164
private static function getValidationGroups(FormInterface $form)
    {
        // Determine the clicked button of the complete form tree
        $clickedButton = null;

        if (method_exists($form, 'getClickedButton')) {
            $clickedButton = $form->getClickedButton();
        }

        if (null !== $clickedButton) {
            $groups = $clickedButton->getConfig()->getOption('validation_groups');

            if (null !== $groups) {
                return self::resolveValidationGroups($groups, $form);
            }
        }

        do {
            $groups = $form->getConfig()->getOption('validation_groups');

            if (null !== $groups) {
                return self::resolveValidationGroups($groups, $form);
            }

            $form = $form->getParent();
        } while (null !== $form);

        return [Constraint::DEFAULT_GROUP];
    }
599395
public function processForm( $form, $formModel ) {

		$formSubmit = $formModel->processFormSubmit( $form );

		$this->triggerNotification( $form );

		return $formSubmit;
    }
905749
protected function buildForm($form = null, $object = null, array $options = [])
    {
        return $this->getFormFactory()->create($form ?: $this->resource, $object, $options);
    }