There are a couple of GET forms already available in Drupal. If you look at the Views filter form or the Search form they both process submissions through a GET request. These forms tend to use a combination of a form, a hook and a controller to manage their rendering and results. What I wanted was an example of a GET form that was more self contained inside a Drupal form object.
To set a form to submit using the GET method you use the setMethod() function of the form state.
$form_state->setMethod('GET');
This is by no means the whole story as there are a few other things to consider. Everything from how you get data from the form input to considerations of the URL structure is important. In fact, I would say that creating GET forms requires a slightly different way of looking at forms than the normal POST request forms.
As an example of how to set up GET forms, I will take a simple POST form and turn into a GET form, detailing the steps involved. The following code is a standard Drupal form that uses a POST request and prints out the input field as a message.
Go to Source
Author: