Checkt form fields by PRE_SET_DATA FormEvent

@param FormEvent $event
776004
public function preSetData(FormEvent $event)
    {
        $user = $event->getData();
        if (null === $user) {
            return;
        }
        if($this->currentUser !== null && $this->currentUser !== $user) {
            $event->getForm()->add($this->factory->createNamed('activated', 'checkbox', null, array(
                'data' => $user->getRegistrationToken() ? false : true,
                'auto_initialize' => false,
                'label' => 'Activated',
                'required' => false,
                'mapped' => false)));
        }
    }
174694
public function check_data($formdata) {
        $field = $this->_name;
        // Check if disable if options are set. if yes then don't add this..
        if (!empty($this->disableelements) && is_array($this->disableelements)) {
            foreach ($this->disableelements as $disableelement) {
                if (array_key_exists($disableelement, $formdata)) {
                    return false;
                }
            }
        }
        if (array_key_exists($field, $formdata) and $formdata->$field !== '') {
            return array('value' => (string)$formdata->$field);
        }
        return false;
    }
450987
public function buildCollection(FormEvent $event, $eventName)
    {
        $form = $event->getForm();

        for ($i = 0; $i < $this->options['max_items']; ++$i) {
            $required = $i < $this->options['min_items'] ? true : false;
            $displayed = $i < $this->options['min_items'] || $this->isDisplayable($event, $i, $eventName);

            $options = $this->options['options'];
            $options['required'] = isset($options['required']) ?
                $options['required'] && $required :
                $required
            ;
            $options['attr'] = array_replace(
                isset($options['attr']) ? $options['attr'] : array(),
                array(
                    'data-collection-id' => $this->options['collection_id'],
                    'data-display' => $displayed ? 'show' : 'hide',
                    'data-position' => $i,
                )
            );

            if (!$displayed) {
                self::disableConstraints($options);
            }

            $form->add($i, $this->options['type'], $options);

            $form->get($i)->add('__to_remove', CheckboxType::class, array(
                'mapped' => false,
                'required' => false,
                'data' => !$displayed,
                'attr' => array(
                    'class' => 'idci_collection_item_remove',
                ),
            ));
        }
    }
95885
public function submit(FormEvent $event)
    {
        $entity = $event->getData();
        
        if ($entity instanceof FileInterface && null === $entity->getId() && null === $entity->getHash()){
            $event->setData(null);
        }
    }
4105
public function preSubmitData(FormEvent $event)
    {
        $form = $event->getForm();
        $data = $event->getData();

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

        foreach ($form as $name => $child) {
            if (!isset($data[$name])) {
                $form->remove($name);
            }
        }
    }
498037
public function preSetData(FormEvent $event)
    {
        $entity = $event->getData();
    
        if ($entity instanceof FileInterface && null !== $entity->getId()){
            try {
                $this->fileManager->copyFileToTemporaryDirectory($entity);
            } catch (\Gaufrette\Exception\FileNotFound $e) {
                $event->setData(null);
            }
        }
    }
922430
public function beforeRender(Event $event)
    {
        parent::beforeRender($event);

        $this->set('detect', $this->detect);
    }
598279
public function onPreSubmitData(FormEvent $event)
    {
        $data = $event->getData();
        if (!array_key_exists('site_root', $data) || false === (bool)$data['site_root']) {
            $location = $this->locationService->loadLocation($data['location']);
            if (1 >= $location->depth) {
                return;
            }
            $parentLocation = $this->locationService->loadLocation($location->parentLocationId);
            $urlAlias = $this->urlAliasService->reverseLookup($parentLocation);
            $data['path'] = $urlAlias->path . '/' . $data['path'];
            $event->setData($data);
        }
    }
1354750
public function check_data($formdata) {
        $field = $this->_name;

        if (array_key_exists($field, $formdata) and $formdata->$field !== '') {
            return array('value' => (string)$formdata->$field);
        }

        return false;
    }
937379
public function changeData(FormEvent $event)
    {
        $data = $event->getData();

        if (null === $data) {
            $data = array();
        }

        if ($data instanceof \Doctrine\Common\Collections\Collection) {
            $event->setData($data->getValues());
        } else {
            $event->setData(array_values($data));
        }
    }
531968
public function beforeUpdate($event)
    {
        $fields = $this->fields;
        $nowDate = gmdate($this->databaseTimeFormat);
        if (!$this->isActuallyDirty()) {
            return;
        }

        if (isset($this->fields['modifiedField']) && !$this->owner->isAttributeChanged($this->fields['modifiedField'])) {
            $this->owner->{$this->fields['modifiedField']} = $nowDate;
        }
        if (isset($this->fields['modifiedByField']) && !$this->owner->isAttributeChanged($this->fields['modifiedByField'])) {
            $this->owner->{$this->fields['modifiedByField']} = self::_getUserId();
        }
    }
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');
        }
    }
291428
public function submit(FormEvent $event)
    {
        try{
            $form = $event->getForm();
            $parentForm = $form->getParent();
            $parentData = $parentForm->getData();

            // Edit case
            if ($parentData) {
                // First, we get the entity class
                $entityClass = get_class($parentData);

                $em = $this->doctrineService->getManagerForClass($entityClass);
                $repository = $em->getRepository('Gedmo\\Translatable\\Entity\\Translation');

                // Gets the translatable fields and their content
                $translatableFields = $this->getTranslatableFields($entityClass);
                $data = $event->getData();

                foreach ($this->localeList as $locale) {
                    if ($locale != $this->currentLocale) {
                        // Here we extract the field values from the submitted data
                        // Here type is useless, just used for getting the field
                        foreach ($translatableFields as $field => $type) {
                            // Here just translate the data
                            $repository->translate($parentData, $field, $locale, $data[$field."-".$locale] );
                        }
                    }
                }

            }
        } catch (\Exception $e) {
            // Case of a non entity object given to the parent form.
            // Unstranslatable case, throw exception.
            $secondException = new \Exception("The object that was given to the form you wanted to translate isn't an entity one. Untranslatable in this case.", $e->getCode(), $e);
            throw $secondException;
        }
    }
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;
            }
        }
    }
1015023
public function beforeFilter(Event $event) {
		// Check security component loaded and disable it for this plugin:
		if (isset($this->Security)) {
			$this->Security->setConfig('validatePost', false);
			$this->Security->setConfig('unlockedActions', ['save']);
		}

		if (isset($this->Csrf) && $this->request->getAttribute('params')['action'] === 'save') {
			$this->getEventManager()->off($this->Csrf);
		}

		if (Configure::read('Feedback')) {
			return null;
		}

		// Throw error, config file required
		throw new NotFoundException('No Feedback config found.');
	}
1321695
public function onPreSetData(FormEvent $event)
    {
        if (!$event->getData() || !$event->getForm()->getConfig()->getOption('removable')) {
            return;
        }

        $event->getForm()->add('remove', 'checkbox', array(
            'label' => $this->options['remove_label']
        ));
    }
656857
protected function populatePreviousData(Form $form) {
		$prepops = EventAttendee::config()->prepopulated_fields;
		if (!$prepops) {
			return;
		}
		$latestattendee = $this->registration->Attendees()
			->sort("LastEdited", "DESC")->first();
		if($latestattendee){
			$form->loadDataFrom($latestattendee, Form::MERGE_DEFAULT, $prepops);	
		}
	}