@param FormView $formView

@return string
349936
public function prepareFormLabel(FormView $formView)
    {
        $labelParts = $this->getLabelParts($formView);

        if ($labelParts[0] === '') {
            $labelParts[0] = 'form';
        }

        // hack for main form: entity_edit, will be entity.edit
        $mainFormParts = explode('_', $labelParts[0]);
        unset($labelParts[0]);

        $labelParts = array_merge($mainFormParts, array('label'), $labelParts);

        foreach ($labelParts as $i => $labelPart) {
            $labelParts[$i] = Helper::camelCaseToUnderscore($labelPart);
        }

        return implode('.', $labelParts);
    }
1357517
public function renderInitcmsFieldAsString(
        $template,
        $object,
        FormView $formView,
        $translationDomain = null
    ) {

        /** @var $fieldDescription \Sonata\DoctrineORMAdminBundle\Admin\FieldDescription */
        $fieldDescription = $formView->vars['sonata_admin']['field_description'];
        $value = '';

        switch ($fieldDescription->getType()) {
            case HiddenType::class:
                $value = $fieldDescription->getValue($object);
                break;
            case BooleanType::class:
                if ($fieldDescription->getValue($object)) {
                    $value = 'positive';
                } else {
                    $value = 'negative';
                }
                break;
            case ChoiceType::class:
            case AutocompleteType::class:
            case IconradioType::class:
            case EntityType::class:
                $choices = $formView->vars['choices'];
                $preferredChoices = $formView->vars['preferred_choices'];
                $choices = array_merge($choices, $preferredChoices);
                $selected = $fieldDescription->getValue($object);
                if (is_object($selected)) {
                    $selected = (string) $selected->getId();
                }
                foreach ($choices as $choice) {
                    if ($choice->value == $selected) {
                        $value = $choice->label;
                    }
                }
                break;
            case DateType::class:
                /** @var $date \DateTime */
                $date = $fieldDescription->getValue($object);
                if ($date) {
                    $value = $date->format('d.m.Y');
                } else {
                    $value = '';
                }
                break;
            case DateTimeType::class:
                /** @var $date \DateTime */
                $date = $fieldDescription->getValue($object);
                if ($date) {
                    $value = $date->format('d.m.Y H:i');
                } else {
                    $value = '';
                }
                break;
            case ModelHiddenType::class:
                $value = $fieldDescription->getValue($object);
                break;
            case CheckboxType::class:
                if ($fieldDescription->getValue($object)) {
                    $value = 'positive';
                } else {
                    $value = 'negative';
                }
                break;
            case TextType::class:
            default:
                $value = $fieldDescription->getValue($object);
                break;
        }

        if ($displayMethod = $fieldDescription->getOption('display_method')) {
            $value = $this->getFieldValue($object, $fieldDescription->getFieldName(), $displayMethod);
        }

        $valueTranslationDomain = $fieldDescription->getTranslationDomain();

        if ('visibility' === $fieldDescription->getName() || 'templateName' === $fieldDescription->getName()) {
            if (array_key_exists('choice_translation_domain', $formView->vars)) {
                $valueTranslationDomain = $formView->vars['choice_translation_domain'];
            }

            $value = $this->translator->trans($value, [], $valueTranslationDomain);
        }

        $options = [
            'page' => $object,
            'field' => $fieldDescription->getName(),
            'value' => $value,
            'translation_domain' => $translationDomain,
        ];

        return $this->templating->render($template, $options);
    }
986361
public function RenderTemplate () {
		$formViewScript = $this->form->GetViewScript();
		return $this->Render(
			static::$formsDir,
			is_bool($formViewScript) ? $this->form->GetId() : $formViewScript
		);
	}
1291721
private function renderForm(Form $form) : string
    {
        $html = '';

        foreach ($form->getComponents() as $component) {
            if ($component instanceof Element) {
                $html .= $this->renderElementAsRow($component);
            } elseif ($component instanceof Group) {
                foreach ($component->getElements() as $element) {
                    $html .= $this->renderElementAsRow($element);
                }
            }
        }

        $table = new Tag('table');
        $table->setAttribute('class', $this->class);
        $table->setHtmlContent($html);

        return $table->render();
    }
1145249
public function getFormErrors(FormView $formView)
    {
        $errors = parent::getFormErrors($formView);

        $formHelper = $this->getFormHelper();

        if (isset($formView['pagepartadmin_' . $this->pagePartAdmin->getContext()])) {
            $errors = array_merge($errors, $formHelper->getRecursiveErrorMessages($formView['pagepartadmin_' . $this->pagePartAdmin->getContext()]));
        }

        return $errors;
    }
1101768
public function getFormCacheIdentifier($formClassName, $formName)
    {
        $shortClassName = end(explode('\\', $formClassName));

        return StringService::get()->sanitizeString($shortClassName . '-' . $formName);
    }
787948
public function render(?string $formId = null, ?string $view = null) : ?string
    {
        if (!$this->enabled()) {
            return null;
        }

        $useView = $view !== null ? $view : $this->view;

        if ($this->viewFactory->exists($useView)) {
            return $this->viewFactory->make($useView, $this->getViewData($formId))->render();
        }

        throw new FileNotFoundException("View '{$useView}' not found");
    }
734633
public function getChildFormView(FormView $formView, $elementId)
    {
        foreach (new \RecursiveIteratorIterator(new FormViewIterator($formView), \RecursiveIteratorIterator::SELF_FIRST) as $name => $formView) {
            if ($name === $elementId) {
                return $formView;
            }
        }
    }
1243764
public function indexAction($formId)
    {
        $form = $this->get('opifer.form.form_manager')->getRepository()->find($formId);

        if (!$form) {
            return $this->createNotFoundException();
        }

        $source = new Entity(Post::class);
        $tableAlias = $source->getTableAlias();
        $source->manipulateQuery(function ($query) use ($tableAlias, $form) {
            $query->andWhere($tableAlias.'.form = :form')->setParameter('form', $form);
        });

        $notificationAction = new RowAction('re-send', 'opifer_form_post_notification');
        $notificationAction->setRouteParameters(['id']);

        $viewAction = new RowAction('view', 'opifer_form_post_view');
        $viewAction->setRouteParameters(['id']);

        $deleteAction = new RowAction('delete', 'opifer_form_post_delete');
        $deleteAction->setRouteParameters(['id']);

        $grid = $this->get('grid');
        $grid->setId('posts')
            ->setSource($source)
            ->setDefaultOrder('id', 'desc')
            ->addRowAction($viewAction)
            ->addRowAction($notificationAction)
            ->addRowAction($deleteAction);

        return $grid->getGridResponse('OpiferCmsBundle:Backend/Post:index.html.twig', [
            'form' => $form
        ]);
    }
400974
public function getFormErrors(FormView $formView)
    {
        $errors = array();

        foreach ($this->widgets as $widget) {
            $errors = array_merge($errors, $widget->getFormErrors($formView));
        }

        return $errors;
    }
229255
private function addFormDeclaration($formTypeName)
    {
        $name = strtolower($this->model);
        $extension = $matches = preg_split('/(?=[A-Z])/', $this->bundle->getName(), -1, PREG_SPLIT_NO_EMPTY);
        $bundleName = $this->getBundlePrefix();
        array_pop($extension);
        $path = $this->bundle->getPath() . '/Resources/config/forms.xml';

        if (!file_exists($path)) {
            $this->renderFile('form/ServicesForms.xml.twig', $path, array());
            $ref = 'protected $configFiles = array(';

            $this->dumpFile(
                $this->bundle->getPath() . '/DependencyInjection/' . implode('', $extension) . 'Extension.php',
                "\n        'forms',",
                $ref
            );die;
        }

        $this->addService($path, $bundleName, $name, $formTypeName);
        $this->addParameter($path, $bundleName, $name);
    }
911990
private function getProvidedFormName(): ?string
    {
        $formName = $this->request->getParameter(self::REQUEST_TOKEN_NAME);
        if (is_null($formName)) {
            $formName = isset($_SERVER[self::HEADER_NAME]) ? $_SERVER[self::HEADER_NAME] : null;
        }
        return $formName;
    }
469352
public function formHasErrors(FormView $form)
    {
        if ($form->vars['errors']->count()) {
            return true;
        }

        foreach ($form->children as $child) {
            if ($this->formHasErrors($child)) {
                return true;
            }
        }

        return false;
    }
765381
protected function _getFormView($view = null)
    {
        if (empty($view) && Arr::in($this->request->getParam('action'), $this->_formActions)) {
            $view = $this->_findViewByRequest();
        }

        return $view;
    }
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(),
                ]
            );
    }
778642
public function render(Form $form, $mode = null): string
	{
		$usedPrimary = false;

		$form->getElementPrototype()->setNovalidate(true);

		foreach ($form->getControls() as $control) {

			if ($control instanceof Controls\BaseControl
				&& !($control instanceof Controls\Checkbox)
				&& !($control instanceof Controls\CheckboxList)
				&& !($control instanceof Controls\RadioList)) {
				$control->getLabelPrototype()->addClass('col-form-label col col-sm-3');
			}

			switch (true) {
				case $control instanceof Controls\Button:
					/** @var string|null $class */
					$class = $control->getControlPrototype()->getAttribute('class');
					if ($class === null || mb_strpos($class, 'btn') === false) {
						$control->getControlPrototype()->addClass($usedPrimary === false ? 'btn btn-primary' : 'btn btn-secondary');
						$usedPrimary = true;
					}
					break;

				case $control instanceof Controls\TextBase:
				case $control instanceof Controls\SelectBox:
				case $control instanceof Controls\MultiSelectBox:
					$control->getControlPrototype()->addClass('form-control');
					break;

				case $control instanceof Controls\Checkbox:
				case $control instanceof Controls\CheckboxList:
				case $control instanceof Controls\RadioList:
					$control->getSeparatorPrototype()->setName('div')->addClass('form-check');
					$control->getControlPrototype()->addClass('form-check-input');
					$control->getLabelPrototype()->addClass('form-check-label');
					break;
			}
		}

		return parent::render($form, $mode);
	}
1065645
private function setFormTheme(FormView $formView, array $theme): void
    {
        $this->get('twig')->getRuntime(FormRenderer::class)->setTheme($formView, $theme);
    }