@param FormInterface $form

@return string
178480
protected function questionFrom(FormInterface $form)
    {
        $question = $this->translator->trans(FormUtil::label($form), [], $this->translationDomainFrom($form));

        return $this->formattedQuestion($question, $this->defaultValueFrom($form));
    }
1229326
public function transform(FormInterface $form)
    {
        return new ConfirmationQuestion($this->questionFrom($form), $this->defaultValueFrom($form));
    }
160019
private function addMainFieldset(FormInterface $form)
    {
        $mainData = $form->addChild($this->getElement('nested_fieldset', [
            'name'  => 'main_data',
            'label' => 'common.fieldset.general',
        ]));
        
        $languageData = $mainData->addChild($this->getElement('language_fieldset', [
            'name'        => 'translations',
            'label'       => 'common.fieldset.translations',
            'transformer' => $this->getRepositoryTransformer('translation', $this->get('page.repository')),
        ]));
        
        $name = $languageData->addChild($this->getElement('text_field', [
            'name'  => 'name',
            'label' => 'common.label.name',
            'rules' => [
                $this->getRule('required'),
            ],
        ]));
        
        $languageData->addChild($this->getElement('slug_field', [
            'name'            => 'slug',
            'label'           => 'common.label.slug',
            'name_field'      => $name,
            'generate_route'  => 'route.generate',
            'translatable_id' => $this->getRequestHelper()->getAttributesBagParam('id'),
            'rules'           => [
                $this->getRule('required'),
            ],
        ]));
        
        $mainData->addChild($this->getElement('checkbox', [
            'name'    => 'publish',
            'label'   => 'common.label.publish',
            'comment' => 'page.comment.publish',
            'default' => 1,
        ]));
        
        $mainData->addChild($this->getElement('text_field', [
            'name'  => 'hierarchy',
            'label' => 'common.label.hierarchy',
            'rules' => [
                $this->getRule('required'),
            ],
        ]));
        
        $mainData->addChild($this->getElement('text_field', [
            'name'  => 'section',
            'label' => 'page.label.section',
        ]));
        
        $mainData->addChild($this->getElement('tree', [
            'name'        => 'parent',
            'label'       => 'page.label.parent',
            'choosable'   => true,
            'selectable'  => false,
            'sortable'    => false,
            'clickable'   => false,
            'items'       => $this->get('page.dataset.admin')->getResult('flat_tree'),
            'restrict'    => $this->getRequestHelper()->getAttributesBagParam('id'),
            'transformer' => $this->getRepositoryTransformer('entity', $this->get('page.repository')),
        ]));
        
        $mainData->addChild($this->getElement('tip', [
            'tip' => $this->trans('page.tip.client_groups'),
        ]));
        
        $mainData->addChild($this->getElement('multi_select', [
            'name'        => 'clientGroups',
            'label'       => 'page.label.client_groups',
            'options'     => $this->get('client_group.dataset.admin')->getResult('select'),
            'transformer' => $this->getRepositoryTransformer('collection', $this->get('client_group.repository')),
        ]));
    }
881356
private static function password(FormInterface $form)
    {
        if ($form->has('credentials_group')) {
            $credentialsGroup = $form->get('credentials_group');

            if ($credentialsGroup->has('plainPassword')) {
                $plainPasswordElement = $credentialsGroup->get('plainPassword');

                if (!empty($plainPasswordElement->getData())) {
                    return 'CsrPassword';
                }
            }
        }
    }
976204
public static function el(array &$form, FormStateInterface $form_state) {
    $trigger = $form_state->getTriggeringElement();
    return NestedArray::getValue($form, array_slice($trigger['#array_parents'], 0, -1));
  }
847168
public static function getValidationGroups(FormInterface $form)
    {
        $cfg = $form->getConfig();

        if ($cfg->hasOption('jquery_validation_groups')) {
            $groups = $cfg->getOption('jquery_validation_groups');
        } else {
            $groups = $cfg->getOption('validation_groups');
        }

        # Is the default validation group used
        if ($groups === null) {
            return array(Constraint::DEFAULT_GROUP);
        }

        # Is the validation suppressed
        if ($groups === false) {
            return array();
        }

        # Is a unsupported group used
        if (!is_string($groups) && is_callable($groups)) {
            throw new UnsupportedException('Callable validation_groups are not supported. Disable jquery_validation or set jquery_validation_groups');
        }

        return (array) $groups;
    }
860389
public function emptyData(FormInterface $form)
    {
        $file = $form->get('bengor_file')->getData();
        if (null === $file) {
            return;
        }

        return new UploadFileCommand(
            $file->getClientOriginalName(),
            file_get_contents($file->getPathname()),
            $file->getMimeType()
        );
    }
1023897
public function createForm(FormInterface $form, PostInterface $post)
    {
        return $this->formFactory->create(PostType::class, $post, ['form_id' => $form->getId()]);
    }
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.
	}
920016
public static function validate(FormInterface $form)
    {
        $groups = array('CsrProfile');

        $groups[] = self::password($form);

        return array_filter(
            array_unique($groups)
        );
    }
1370219
public function processForm(FormInterface $form, $andFlush = true)
    {
        $data = $form->getData();

        $this->save($data);

        return $data;
    }
1044075
public function transform(FormInterface $form)
    {
        $formView = $form->createView();

        $question = new AlwaysReturnKeyOfChoiceQuestion($this->questionFrom($form), $formView->vars['choices'], $this->defaultValueFrom($form));

        if ($form->getConfig()->getOption('multiple')) {
            $question->setMultiselect(true);
        }

        return $question;
    }
572586
public function renderForm(Form $form)
	{
		foreach ($form as $element)
		{
			$this->render($element);
		}

		$tableRender = new SimpleTable();
		$tableContent = $tableRender->renderTable($this->table);

		return Html::tag('form', $form->getAttributes(), $tableContent);
	}
596861
public function visitFormAction(FormActionInterface $formAction)
    {
        $template = "form-action/{$formAction->getType()}.twig";

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "label" => $formAction->getLabel(),
                    "target" => $formAction->getTarget(),
                    "classes" => $formAction->getClasses(),
                    "data" => $formAction->getData(),
                ]
            );
    }
1189091
protected function prepareFilterValues(FormInterface $form)
    {
        $config = $form->getConfig();
        $values = $this->dataExtractor->extractData($form, $config->getOption('data_extraction_method', 'default'));

        if ($config->hasAttribute('filter_options')) {
            $values = array_merge($values, $config->getAttribute('filter_options'));
        }

        return $values;
    }
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();
    }
958727
protected function getElementId(Form $form)
    {
        /** @var Form $parent */
        $parent = $form->getParent();
        if (null !== $parent) {
            return $this->getElementId($parent) . '_' . $form->getName();
        } else {
            return $form->getName();
        }
    }