function Form::getUri
Gets the URI of the form.
The returned URI is not the same as the form "action" attribute. This method merges the value if the method is GET to mimics browser behavior.
Overrides AbstractUriElement::getUri
File
-
vendor/
symfony/ dom-crawler/ Form.php, line 180
Class
- Form
- Form represents an HTML form.
Namespace
Symfony\Component\DomCrawlerCode
public function getUri() : string {
$uri = parent::getUri();
if (!\in_array($this->getMethod(), [
'POST',
'PUT',
'DELETE',
'PATCH',
])) {
$currentParameters = [];
if ($query = parse_url($uri, \PHP_URL_QUERY)) {
parse_str($query, $currentParameters);
}
$queryString = http_build_query(array_merge($currentParameters, $this->getValues()), '', '&');
$pos = strpos($uri, '?');
$base = false === $pos ? $uri : substr($uri, 0, $pos);
$uri = rtrim($base . '?' . $queryString, '?');
}
return $uri;
}