@param FormInterface   $form
@param HelperSet       $helperSet
@param InputInterface  $input
@param OutputInterface $output

@throws CanNotInteractWithForm If the input isn't interactive or a compound form

@return array
7700
public function interactWith(
        FormInterface $form,
        HelperSet $helperSet,
        InputInterface $input,
        OutputInterface $output
    ) {
        if (!$input->isInteractive()) {
            throw new CanNotInteractWithForm('This interactor only works with interactive input');
        }

        if (!FormUtil::isCompound($form)) {
            throw new CanNotInteractWithForm('Expected a compound form');
        }

        $submittedData = [];

        foreach ($form->all() as $name => $field) {
            try {
                $submittedData[$name] = $this->formInteractor->interactWith($field, $helperSet, $input, $output);
            } catch (NoNeedToInteractWithForm $exception) {
                continue;
            }
        }

        return $submittedData;
    }
1358940
public function buildForm(FormBuilderInterface $builder): FormInterface
    {
        $this->buildFilterForm($builder);
        $this->buildSortableForm($builder);

        $this->form = $builder->getForm();

        return $this->form;
    }
587129
private function getTranslationDomain(FormInterface $form)
	{
		$translation = $form->getConfig()->getOption('translation_domain');
		if (empty($translation))
		{
			$parent = $form->getParent();

			if (empty($parent))
			    $translation = 'messages';

			while (empty($translation))
			{
				$translation = $parent->getConfig()->getOption('translation_domain');
				$parent      = $parent->getParent();
				if (! $parent instanceof FormInterface && empty($translation))
					$translation = 'messages';
			}
		}

		return $translation = $translation === 'messages' ? null : $translation;  // Allow the Symfony Default setting to be used by returning null.
	}
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];
    }
531830
public function resolve(FormInterface $form)
    {
        $types = FormUtil::typeAncestry($form);

        foreach ($types as $type) {
            if (isset($this->transformers[$type])) {
                return $this->transformers[$type];
            }
        }

        throw new CouldNotResolveTransformer(
            sprintf(
                'Could not find a transformer for any of these types (%s)',
                implode(', ', $types)
            )
        );
    }
425540
public function getFlattenErrors(FormInterface $form = null, $subForm = false)
    {
        $form    = $form ?: $this->form;
        $flatten = [];

        foreach ($form->getErrors() as $error) {
            if ($subForm) {
                $flatten[] = $error->getMessage();
            } else {
                $path = $error->getCause()->getPropertyPath();

                if (!array_key_exists($path, $flatten)) {
                    $flatten[$path] = [$error->getMessage()];
                    continue;
                }

                $flatten[$path][] = $error->getMessage();
            }
        }

        $subForm = true;
        foreach ($form->all() as $key => $child) {
            $childErrors = $this->getFlattenErrors($child, $subForm);

            if (!empty($childErrors)) {
                $flatten[$key] = $childErrors;
            }
        }

        return $flatten;
    }
216185
public function form($form = null)
    {
        if (func_num_args() === 1) {
            $form = $form ?: [];
            $this->_form = $form;
            $this->set($form);
            return $this;
        }
        return $this->_form;
    }
695767
protected function isElementHasError(ElementInterface $element, FormInterface $form)
    {
        if ($element->getMessages()) {
            return true;
        }

        $elementName = $this->normalizeElementName($element->getName());
        $elements = $this->getInvalidFieldsetElements($element, $form);
        if (isset($elements[$elementName]) && $elements[$elementName] === $element) {
            return true;
        }

        return false;
    }
851147
protected function defaultValueFrom(FormInterface $form)
    {
        $defaultValue = $form->getData();
        if (is_array($defaultValue)) {
            $defaultValue = implode(',', $defaultValue);
        }

        return $defaultValue;
    }
605658
private function askIfExistingEntryShouldBeAdded(
        HelperSet $helperSet,
        InputInterface $input,
        OutputInterface $output,
        $entryNumber
    ) {
        return $this->questionHelper($helperSet)->ask(
            $input,
            $output,
            new ConfirmationQuestion(
                Format::forQuestion(
                    strtr(
                        'Add entry {entryNumber} to the submitted entries?',
                        [
                            '{entryNumber}' => $entryNumber,
                        ]
                    ),
                    'y'
                ),
                true
            )
        );
    }
1365898
protected function createCommandFromData(FormInterface $form, Options $options)
    {
        $reflection = new ReflectionClass($this->getCommandClass());
        $data = [];
        /** @var FormInterface $field */
        foreach ($form as $field) {
            $data[$field->getName()] = $field->getData();
        }

        return $reflection->newInstanceArgs($data);
    }
498972
public function buildForm(FormBuilderInterface $builder): FormInterface
    {
        $this->buildFilterActions($builder);
        $this->buildDataGridActions($builder);

        $this->form = $this->getQueryHandler()->buildForm($builder);

        return $this->form;
    }
433175
protected function getErrorsFromForm(FormInterface $form)
    {
        $errors = [];
        /** @var FormError $error */

        if($form->getErrors()->count() === 0 && $form->isRoot() && !$form->isValid()){
            $errors["_self"] = "Empty post data";
        }

        foreach ($form->getErrors() as $error) {
            $key = $error->getOrigin()->getName();
            $errors[($form->isRoot()) ? "_self" : $key] = $error->getMessage();
        }

        foreach ($form->all() as $childForm) {
            if ($childForm instanceof FormInterface) {
                if ($childErrors = $this->getErrorsFromForm($childForm)) {
                    unset($errors["_self"]);
                    $errors = array_merge_recursive($errors, $childErrors);
                }
            }
        }

        return $errors;
    }
267566
public function buildForm(array $form, FormStateInterface $form_state, $sid = NULL) {
    $this->sid = (int) $sid;
    if ($this->sid) {
      $slide = $this->databaseSliders->loadSlide($sid);
      $this->slide = $slide;      
    }
    return parent::buildForm($form, $form_state);
  }
643454
protected function createInstance(
        InputInterface $input,
        OutputInterface $output,
        Form $form = null
    ) {
        if (!isset($form)) {
            $form = new Form();
        }

        return $form
            ->setInput($input)
            ->setOutput($output)
            ->setHelperSet($this->getHelperSet());
    }
178480
protected function questionFrom(FormInterface $form)
    {
        $question = $this->translator->trans(FormUtil::label($form), [], $this->translationDomainFrom($form));

        return $this->formattedQuestion($question, $this->defaultValueFrom($form));
    }
676519
public static function typeAncestry(FormInterface $form)
    {
        $types = [];
        self::typeAncestryForType($form->getConfig()->getType(), $types);

        return $types;
    }