Validates the form and its domain object.

@param FormEvent $event The event object
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);
            }
        }
    }
765292
public function validateEvent($event)
    {
        if (!is_string($event)
            || strlen($event) > 1000
            || strlen($event) < 1
        ) {
            throw new InvalidArgumentException(
                'Event name must be a non empty string of at most 1,000 ' .
                'characters',
                400
            );
        }

        return $this;
    }
869184
public function submit(FormEvent $event)
    {
        $image = $event->getData();

        if ($image && $image->isNew() && !$image->hasFile()) {
            $event->setData(null);
        }
    }
487060
public boolean handleEvent(ValidationEvent event) {
		LOGGER.info("");
		LOGGER.info("EventT");
		LOGGER.info("\tSeverity: " + event.getSeverity());
		LOGGER.info("\tMessage: " + event.getMessage());
		LOGGER.info("\tLinked Excpetion: " + event.getLinkedException());
		LOGGER.info("\tLocator");
		LOGGER.info("\tLine Number: "
				+ event.getLocator().getLineNumber());
		LOGGER.info("\tColumn Number: "
				+ event.getLocator().getColumnNumber());
		LOGGER.info("\tOffset: " + event.getLocator().getOffset());
		LOGGER.info("\tObject: " + event.getLocator().getObject());
		LOGGER.info("\tNode: " + event.getLocator().getNode());
		LOGGER.info("\tURL: " + event.getLocator().getURL());
		return true;
	}
482989
public function postSubmitDocumentParent(FormEvent $event)
    {
        $document = $event->getData();

        if ($document->getParent()) {
            return;
        }

        $form = $event->getForm();
        $webspaceKey = $form->getConfig()->getAttribute('webspace_key');
        $parent = $this->documentManager->find($this->sessionManager->getContentPath($webspaceKey));

        if (null === $parent) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Could not determine parent for document with title "%s" in webspace "%s"',
                    $document->getTitle(),
                    $webspaceKey
                )
            );
        }

        $document->setParent($parent);
    }
532432
public function postSubmit(FormEvent $event)
    {
        // Suppress validation
        $event->stopPropagation();

        $constraints = [];
        $attributes['class'] = 'js-change-urlchooser';

        $form = $event->getForm()->getParent();
        $linkType = $event->getData();

        if ($linkType) {
            $form->remove('link_url');

            switch ($linkType) {
                case URLChooserType::INTERNAL:
                    $attributes['choose_url'] = true;

                    break;
                case URLChooserType::EXTERNAL:
                    $attributes['placeholder'] = 'https://';
                    $constraints[] = new Url();

                    break;
                case URLChooserType::EMAIL:
                    $constraints[] = new Email();

                    break;
            }

            $form->add('link_url', TextType::class, array(
                'label' => 'URL',
                'required' => true,
                'attr' => $attributes,
                'constraints' => $constraints,
                'error_bubbling' => true,
            ));
        }
    }
694086
public function createForm(FormEvent $event): void
    {
        $admin = $event->getAdmin();
        $action = $admin->getAction();
        $configuration = $action->getConfiguration();

        if (!$configuration->get('use_form')) {
            return;
        }
        $entity = null;

        if (LAGAdminBundle::LOAD_STRATEGY_UNIQUE === $configuration->get('load_strategy')) {
            if (!$admin->getEntities()->isEmpty()) {
                $entity = $admin->getEntities()->first();
            }
        }

        if ('create' === $action->getName() || 'edit' === $action->getName()) {
            $form = $this->adminFormFactory->createEntityForm($admin, $event->getRequest(), $entity);
            $event->addForm($form, 'entity');
        }

        if ('delete' === $action->getName()) {
            $form = $this->adminFormFactory->createDeleteForm($action, $event->getRequest(), $entity);
            $event->addForm($form, 'delete');
        }
    }
1100577
public function postSubmit(FormEvent $e)
    {
        if ($e->getForm()->has($this->property) && $e->getForm()->getRoot()->isValid()) {
            $menuItem = $e->getForm()->get($this->property)->getData();

            if ($menuItem->isAddToMenu()) {
                if (!$menuItem->getTitle()) {
                    $menuItem->setTitle((string)$e->getData());
                }
                $menuItem->setPath($this->provider->url($e->getData(), array('aliasing' => false)));
                $this->mm->addItem($menuItem);
            } elseif ($menuItem->getId()) {
                $this->mm->removeItem($menuItem);
            }
        }
    }
808961
public function handle(DomainEvent $event) : void {
        $method = lcfirst($this->getShortName($event));
        if (method_exists($this, $method)) {
            $this->$method($event);
        }
    }
862885
public function preSubmit(FormEvent $event)
    {
        $form = $event->getForm();
        $formHash = $this->getFormHash($form);
        $this->submittedDataPlain[$formHash] = $event->getData();
    }
95336
public function preSetData(FormEvent $event)
    {
        $data = $event->getData();
        $form = $event->getForm();

        $fields = $form->getConfig()->getOption('fields');

        if (null === $data || '' === $data) {
            $data = [];
        }

        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
            throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
        }
        // Sorting values so that they display in sorted order of the attributes
        uasort($data, function ($a, $b) {
            return $a->getAttribute()->getSort() > $b->getAttribute()->getSort();
        });

        /**
         * @var string $name
         * @var Value  $value
         */
        foreach ($data as $name => $value) {
            //Do not add fields when there not in fields value when giving.
            if (!empty($fields) && !in_array($name, $fields)) {
                continue;
            }
            // Do not add fields dynamically if they've already been set statically.
            // This allows us to override the formtypes from inside the form type
            // that's calling this subscriber.
            if ($form->has($name)) {
                continue;
            }
            $form->add($name, ValueType::class, [
                'label' => $value->getAttribute()->getDisplayName(),
                'required' => $value->getAttribute()->getRequired(),
                'attribute' => $value->getAttribute(),
                'entity' => get_class($value),
                'value' => $value,
                'attr' => ['help_text' => $value->getAttribute()->getDescription()]
            ]);
        }
    }
1105328
public function onFormSuccess(FormEvent $event)
    {
        $form = $event->getForm();

        $result = $this->createResult($form);

        if ($form->getStoreResults()) {
            $this->storeResult($form, $result);
        }

        if ($form->getSendMail()) {
            $this->sendMail($form, $result);
        }

        $successUrl = $form->getSuccessUrl();

        if ($successUrl != null) {
            $redirectResponse = new RedirectResponse($successUrl);
            $redirectResponse->send();
        }
    }
1352632
public function onLayoutBoxFormInit(FormEvent $event)
    {
        $builder       = $event->getFormBuilder();
        $form          = $event->getForm();
        $configurators = $this->container->get('layout_box.configurator.collection')->all();
        $resource      = $event->getResource();
        $boxSettings   = $resource->getSettings();
        
        foreach ($configurators as $configurator) {
            if ($configurator instanceof LayoutBoxConfiguratorInterface) {
                $defaults = [];
                if ($resource->getBoxType() == $configurator->getType()) {
                    $defaults = $boxSettings;
                }
                
                $configurator->addFormFields($builder, $form, $defaults);
            }
        }
    }
698904
final protected function apply(DomainEvent $event) : void
    {
        $this->handleEventInAggregate($event);
        parent::raise($event);
    }
193012
public function preSetData(FormEvent $event)
    {
        $form = $event->getForm();

        foreach ($form as $name => $child) {
            $form->remove($name);
        }
    }
689948
public function onPreSerialize(ObjectEvent $event)
    {
        $configuredType = $event->getObject();

        if ($configuredType instanceof ConfiguredType) {
            try {
                $configurationArray = json_decode($configuredType->getConfiguration(), true);
                $extraFormType = $this->registry->getType($configurationArray['form_type']);
                $configuredType->setExtraFormType($extraFormType);
            } catch (\Exception $e) {
                return;
            }
        }
    }
391935
public function preSubmit(FormEvent $event): void
    {
        $rawData = $event->getData();
        $form = $event->getForm();
        $data = $form->getData();

        Assert::isInstanceOf($data, CustomerInterface::class);

        // if email is not filled in, go on
        if (!isset($rawData['email']) || empty($rawData['email'])) {
            return;
        }

        /** @var CustomerInterface|null $existingCustomer */
        $existingCustomer = $this->customerRepository->findOneBy(['email' => $rawData['email']]);
        if (null === $existingCustomer || null !== $existingCustomer->getUser()) {
            return;
        }

        $existingCustomer->setUser($data->getUser());
        $form->setData($existingCustomer);
    }