Skip to main content

Posts

Showing posts from July, 2020

Redirection In Drupal 8 Programatcially

Redirection In Drupal 8  In this post we can learn about the ways we can make redirect in Drupal 8. You can make a custom redirect according to the context in many ways. Form Redirect      We can use the formstate object to redirect from form.     Currently below two methods are available from Drupal\Core\Form  formstate to build  a    \Symfony\Component\HttpFoundation\RedirectResponse  for redirection. 1) setRedirect  function setRedirect($route_name, array $route_parameters = [], array $options = []) This method will call the setRedirectUrl function inside it. 1) route_parameters - optional argument 2) route_name -  The name of the route name. 3) options -    (optional) An associative array of additional URL options, with the    *   following elements:    *   - 'query': An array of query key/value-pairs (without any URL-encoding)    *     to append to the URL .    *   - 'fragment': A fragment identifier (named anchor) to append to the URL.    *     Do not incl