Get parameter from a form for creating a pager URL.

@param Form $form

@return array
2101
public function getPrmForUrl(Form $form)
    {
        $ret = array();
        foreach ($form->getData() as $k => $data) {
            if (isset($data['value'])) {
                $data['value'] = $this->prepareDataForUrl($data['value'], $form->get($k)->get('value'));
                $ret[$k] = $data;
            }
        }

        return count($ret) ? array($form->getName() => $ret) : array();
    }
887083
public function doSaveLink($data, Form $form)
    {
        $link = $this->getLinkObject() ? $this->getLinkObject() : Link::create();
        $form->saveInto($link);

        try {
            $link->write();
        } catch (ValidationException $e) {
            $form->sessionMessage($e->getMessage(), 'bad');

            return $form->forTemplate();
        }

        $this->setValue($link->ID);
        $this->setForm($form);

        return $this->FieldHolder();
    }
630510
protected function getViewParameters(Request $request, Form $form = null, $data = null): array
    {
        $parameters = [
            'isAjax' => $request->isXmlHttpRequest(),
            'target' => $request->get('target'),
            'success' => $request->get('success'),
            'isModal' => $request->isXmlHttpRequest() && $request->get('modal'),
            'listPath' => $this->getAdminListPath($data),
            'admin' => $this->admin,
        ];

        if ($form) {
            $parameters['form'] = $form->createView();
        }
        if ($data) {
            $parameters['data'] = $data;
        }

        return $parameters;
    }
1221180
public function setActionUrl(Form $form)
    {

        $current = explode('/', rtrim($this->urlProvider->currentUrl(), '/'));

        $lastSegment = array_pop($current);

        if (in_array($lastSegment, ['create','edit'])) {

            $parentUrl = implode('/', $current);

            $form->setAction($parentUrl);

        } else {
            $form->setAction($this->urlProvider->currentUrl());
        }

        if ($lastSegment == 'create') {
            $form->setVerb('post');
            return;
        }

        if($lastSegment == 'edit') {
            $form->setVerb('put');
            return;
        }

    }
1113235
public function getQueryArgs($formValue)
    {
        // TODO: Implement getQueryArgs() method.
        $arr = [];
        if (is_array($formValue) && !empty($formValue)) {
            $arr = $formValue;
        }

        if (is_string($formValue) && !empty($formValue)) {
            $arr = array_filter(explode(',', $formValue));
        }

        return [$this->field, $arr];
    }
87766
public static function populateForm(Form $form)
	{
		if (static::$builder === null)
		{
			static::setBuilder(new V1Model);

			static::$builder->setWrapperElement(null);
		}

		$elements = static::$builder->generate(get_called_class());

		return $form->setContents($elements);
	}
694714
protected function getRedirectParams(array $form, FormStateInterface $form_state) {
    $params = [
      'location' => array_filter($form_state->getValue('location')),
      'class' => $form_state->getValue('class_name'),
      'category' => $form_state->getValue('category'),
      'filter_length' => $form_state->getValue('filter_length'),
    ];

    // Time of day is optional.
    $time_of_day = array_filter($form_state->getValue('time_of_day'));
    if (!empty($time_of_day)) {
      $params['time_of_day'] = array_values($time_of_day);
    }

    // Get date.
    /** @var \Drupal\Core\Datetime\DrupalDateTime $date */
    $date = $form_state->getValue('filter_date');
    $params['filter_date'] = $date->format(self::$dateFilterFormat);

    // Toggle filter_length if user has selected more than 1 location and week period.
    if ($params['filter_length'] == 'week' && count($params['location']) > 1) {
      $params['filter_length'] = 'day';
      drupal_set_message(t('Search results across multiple locations are limited to a single day.'), 'warning');
    }

    return $params;
  }
741838
public function generateFormID($form)
    {
        if ($id = $form->getHTMLID()) {
            return Convert::raw2htmlid($id);
        }

        $reflection = new ReflectionClass($form);
        $shortName = str_replace(array('.', '/'), '', $form->getName());
        return Convert::raw2htmlid($reflection->getShortName() . '_' . $shortName);
    }
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();
    }
1126822
protected function handleCreate(Request $request, Form $form, AbstractPage $page)
    {
        $form->handleRequest($request);

        if ($form->isValid() && !$request->isXmlHttpRequest()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($page);
            $em->flush();

            return $this->redirect($this->getRedirectUrl($request));
        }

        return [
            'page' => $page,
            'form' => $form->createView()
        ];
    }
1103798
public function keyValues($form = null)
    {
        if (null === $this->configs) {
            $this->loadConfigs();
        }

        $keys = ($form) ? call_user_func([$form, 'getFields']) : [];

        $array = [];
        foreach ($this->configs as $key => $config) {
            if ($form && !in_array($key, $keys)) {
                continue;
            }

            $array[$key] = $config->getValue();
        }

        return $array;
    }
485158
protected function processChildren($form)
    {
        $result = array();
        // If this field has children - process them
        foreach ($form as $name => $child) {
            if ($this->isProcessableElement($child)) {
                $childModel = $this->createJsModel($child);
                if (null !== $childModel) {
                    $result[$name] = $childModel;
                }
            }
        }

        return $result;
    }
328366
public function get($url, array $vars = []) {
        // concat form_params to url if get method
        if(!empty($vars['form_params'])) {
            $url .= '?'.http_build_query($vars['form_params']);
            // don't forward it
            unset($vars['form_params']);
        }
        return $this->call('GET', $url, $vars);
    }
420593
protected function getParams()
    {
        $reserved = [
            $this->config('prefix', '').'sort',
            $this->config('prefix', '').'fields',
            $this->config('prefix', '').'limit',
            $this->config('prefix', '').'with',
            $this->config('prefix', '').'page',
        ];

        return $this->params ?: $this->request->except($reserved);
    }
1314443
public function getNavFormParams()
    {

        if (($sParams = $this->getViewConfigParam('navformparams')) === null) {
            $oStr = getStr();
            $sParams = '';
            $aNavParams = $this->getConfig()->getTopActiveView()->getNavigationParams();
            foreach ($aNavParams as $sName => $sValue) {
                if (isset($sValue)) {
                    $sParams .= "<input type=\"hidden\" name=\"{$sName}\" value=\"";
                    $sParams .= $oStr->htmlentities($sValue) . "\" />\n";
                }
            }
            $this->setViewConfigParam('navformparams', $sParams);
        }

        return $sParams;
    }
69586
private function getConstraints(FormInterface $form): array
    {
        $constraints = [];
        foreach ($this->readerRegistry->all() as $reader) {
            $constraints = array_merge($constraints, $reader->read($form));
        }

        return $constraints;
    }
1175166
public function getErrorMessages(Form $form)
    {
        $errors = '';

        foreach ($form->getErrors() as $key => $error) {
            $errors .= $error->getMessage().', ';
        }

        /** @var Form $child */
        foreach ($form->all() as $child) {
            if (!$child->isValid()) {
                $fieldName = $child->getConfig()->getOption('label', null);

                if (empty($fieldName)) {
                    $fieldName = $child->getName();
                }

                $errors .= sprintf("[%s] %s, ", $fieldName, $this->getErrorMessages($child));
            }
        }

        return rtrim($errors, ', ');
    }